| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- import constant from '../../utils/constant';
- const app = getApp();
- Page({
- data: {
- HelpList:constant.arrFamilyHelpList,
- PanelType:0,
- },
- onPullDownRefresh: function () {
- var that = this;
- if (that.data.PanelType==0){
- app.globalData.FamilyUsers=[];
- var url = "GetUserFamily?UserID=" + app.globalData.userInfo.UserID + "&IsWeb=false";
- main.getData(url, function (data) {
- if (data) {
- if (data.length > 0) {
- app.globalData.FamilyUsers = data;
- wx.redirectTo({
- url: 'family',
- })
- }
- }
- });
- }
-
- wx.stopPullDownRefresh();
- },
- onShow: function (options) {
- var that = this;
- if (app.globalData.userInfo.IsShow == 1) {
- var today=wx.getStorageSync("AccreditLimitTime");
- if (common.formatTime(new Date(),"-")>today){
- wx.navigateTo({
- url: '../index/accredit',
- });
- }
- }
- },
- onLoad: function (options) {
- var that = this;
- var panelType=0;
- if (options.PanelType)
- panelType=options.PanelType;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- FamilyUsers:app.globalData.FamilyUsers,
- IsMember:app.globalData.userInfo.IsMember,
- PanelType:panelType,
- });
- wx.setNavigationBarColor({
- frontColor: "#000000",
- backgroundColor: "#ffffff"
- });
- if (panelType==1){
- that.setData({
- MainUserID:options.MainUserID,
- NickName:options.NickName,
- HelpList:constant.arrFamilyHelpListAccept,
- Time:options.Time,
- });
- that.download(options.AvatarUrl);
- wx.setNavigationBarTitle({
- title: '邀请函',
- });
- }
- },
- download: function (avatarUrl) {
- var that = this;
- wx.downloadFile({
- url: avatarUrl,
- success(res) {
- if (res.statusCode === 200) {
- that.setData({
- AvatarUrl: res.tempFilePath,
- });
- }
- }
- });
- },
- showHelp:function(e){
- var index=e.currentTarget.dataset.index;
- var expand=e.currentTarget.dataset.expand;
- this.data.HelpList[index].IsExpand=!this.data.HelpList[index].IsExpand;
- this.setData({
- HelpList:this.data.HelpList,
- });
- },
- gotoReLaunch: function (e) {
- var url = e.currentTarget.dataset.url;
- wx.reLaunch({
- url: url,
- });
- },
- addUser:function(e){
- var that=this;
- if (!app.globalData.userInfo.IsMember){
- wx.showModal({
- title: '添加失败',
- content: '只有秒过续费用户可使用。未续费和已过期的不能使用。',
- showCancel: false,
- confirmText: "知道了",
- success(res) {},
- });
- }
- else if (that.data.FamilyUsers.length>=2){
- wx.showModal({
- title: '添加失败',
- content: '最多添加2名用户。如要替换请解除后重新添加。',
- showCancel: false,
- confirmText: "知道了",
- success(res) {},
- });
- }
- },
- addUser2:function(e){
- setTimeout(function () {
- wx.showModal({
- title: '等待对方接受邀请',
- content: '请尽快与对方联系确认邀请',
- showCancel: false,
- confirmText: "知道了",
- });
- }, 3000);
- },
- removeUser:function(e){
- var that=this;
- if (that.data.FamilyUsers.length==0){
- wx.showModal({
- title: '解除失败',
- content: '尚未添加用户,不能解除。',
- showCancel: false,
- confirmText: "知道了",
- success(res) {},
- });
- }
- else{
- wx.showModal({
- title: '解除家庭用户吗',
- content: '解除后重启小程序。对方不能再使用您的秒过。可重新添加用户。',
- showCancel: true,
- confirmText: "解除",
- success(res) {
- if (res.confirm) {
- main.getData("updateMiaoguoFamily?UpdateType=delete&UserID=" + app.globalData.userInfo.UserID, function (data) {
- app.globalData.FamilyUsers=[];
- wx.reLaunch({
- url: '../index/index?type=family',
- });
- });
- }
- },
- });
- }
- },
- accept:function(){
- var that=this;
- if (!app.globalData.userInfo.IsMember){
- wx.showModal({
- title: '接受失败',
- content: '未续费的和有效期已过期的用户不能加入「家庭用户」。请先续费再接受邀请。',
- showCancel: false,
- confirmText: "知道了",
- success(res) {},
- });
- }
- else if (app.globalData.userInfo.ChildUserID>0){
- wx.showModal({
- title: '接受失败',
- content: '「帐号绑定」的子账号不能加入「家庭用户」。只有有效期内的续费用户才能加入。',
- showCancel: false,
- confirmText: "知道了",
- success(res) {},
- });
- }
- else if (that.data.FamilyUsers.length>=2){
- wx.showModal({
- title: '接受失败',
- content: '最多添加2名用户。如要替换请解除后重新添加。',
- showCancel: false,
- confirmText: "知道了",
- success(res) {},
- });
- }
- else if (that.data.MainUserID==app.globalData.userInfo.UserID){
- wx.showModal({
- title: '接受失败',
- content: '不能自己和自己建立家庭帐号,请发给另外一个微信号。',
- showCancel: false,
- confirmText: "知道了",
- success(res) {},
- });
- }
- else{
- wx.showModal({
- title: '接受邀请吗',
- content: '接受后重启小程序。对方可使用您的秒过。',
- showCancel: true,
- confirmText: "接受",
- success(res) {
- if (res.confirm) {
- main.getData("updateMiaoguoFamily?UpdateType=add&Time="+that.data.Time+"&UserID=" + that.data.MainUserID+"&NewUserID=" + app.globalData.userInfo.UserID, function (data) {
- if (data==0){
- app.globalData.FamilyUsers=[];
- wx.reLaunch({
- url: '../index/index?type=family',
- });
- }
- else if (data<0){
- var content="";
- if (data==-1)
- content="本邀请已过期,请联系对方重新设置。";
- else if (data==-2)
- content="您已经加入该「家庭用户」了。重启小程序后,在首页即可切换帐号。";
- else if (data==-3)
- content="对方的「家庭用户」名额已满,请联系对方重新设置。";
-
- wx.showModal({
- title: '接受失败',
- content: content,
- showCancel: false,
- confirmText: "知道了",
- success(res) {
- if (data==-2){
- app.globalData.FamilyUsers=[];
- wx.reLaunch({
- url: '../index/index?type=family',
- });
- }
- },
- });
- }
-
- });
- }
- },
- });
- }
- },
- onShareAppMessage: function () {
- if (this.data.PanelType==0 && this.data.FamilyUsers.length<2 && this.data.IsMember==1) {
- var path=app.globalData.SharePath + '?type=family&PanelType=1&MainUserID=' + app.globalData.userInfo.UserID;
- path += "&Time=" + common.formatTime(new Date(),"-");
- path += "&NickName=" + app.globalData.userInfo.NickName;
- path += "&AvatarUrl=" + app.globalData.userInfo.AvatarUrl;
-
- return {
- title: app.globalData.ShareTitle,
- path: path,
- imageUrl: app.globalData.uploadImageUrl +"web/program_screenshot_jtyh.png",
- }
- }
- else{
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- }
- },
- })
|