// pages/myMember/myMember.js let App = getApp(); let util = require("../../utils/util.js"); var WxParse = require("../../wxParse/wxParse.js"); Page({ /** * 页面的初始数据 */ data: { appAssetsUrl: App.appAssetsUrl, appAssetsUrl2: App.appAssetsUrl2, bottomLeft: App.bottomLeft, params: { type: "wx", }, bottom: 0, //判断 禁用 checked: true, disable: false, statusBarHeight: "", stHeight: "", statusBarMH: "", detail: "", user: {}, agree: true, activeTitle: false, wgFillInfo: {}, memberPoints: {}, isDeductiblePrice: null, taskCode: null, isDeduction: false, currentImg: null, integral: null, isDev: true, memberNotice: '', botCheck: 0 }, // 自定义高度处理 height() { const { platform, statusBarHeight } = wx.getSystemInfoSync(); let height = statusBarHeight + 4; //ios 24px let mH = statusBarHeight + 4; if (platform.toLowerCase() == "android") { height += 4; //android 28px mH += 4; } height = height + 38; // 胶囊高度 32px 下边框6px height 状态栏高度 this.setData({ stHeight: height - mH + "px", statusBarHeight: height + "px", statusBarMH: mH + "px", }); }, // 判断是否开发huanjing env(){ let that = this App._post_form('wgfillinfo/apiSelectwgfillinfo', 'application/json', null, function (res) { if (res.code === 0) { // that.setData({ // isDev: res.wgFillInfo.isDev // }) if(res.wgFillInfo.isDev) { wx.switchTab({ url: '/pages/home/index/index' }) } } } ) }, goback() { wx.navigateBack({ delta: 1, }); }, /** * 查询用户数据根据id */ PushVipInfo() { let _this = this; let id = util.getUserId(); if (id) { let params = { id, }; App._post_form( "member/apiSelectMeberInfo", "application/json", params, function (res) { if (res.code === 0) { wx.setStorageSync("USER", res.member); _this.setData({ detail: res.member, }); if (res.member.memberState != 2) { _this.setData({ currentImg: 2, taskCode: "LIFELONG", }); } } else { wx.removeStorageSync("USER"); wx.navigateTo({ url: "/pages/login", }); } } ); } }, getVipSelect() { let _this = this App._get("wgfillinfo/apiSelectwgfillinfo", {}, (res) => { if (res.code === 0) { this.setData({ wgFillInfo: res.wgFillInfo, }); WxParse.wxParse('memberNotice', 'html', res.wgFillInfo.memberNotice, _this, 0); } }); }, getPointDeduction() { let code; if (this.data.detail.memberState == 0) { if (this.data.currentImg == 1) { code = 4; } else if (this.data.currentImg == 2) { code = 5; } } else if (this.data.detail.memberState == 1) { code = 6; } App._get( "member/memberPointDeduction", { id: this.data.detail.id, code: code, }, (res) => { if (res.code == 0) { this.setData({ memberPoints: res.data, }); } } ); }, changeVip(e) { console.log(e, 123); if (this.data.detail.memberState == e.currentTarget.dataset.currentimg) { wx.showToast({ icon: "none", title: "已是当前VIP", }); return false; } else if (this.data.detail.memberState == 2) { wx.showToast({ icon: "none", title: "已是终身VIP", }); return false; } let taskCode; if (e.currentTarget.dataset.currentimg == 1) { taskCode = "ANNUAL_FEE"; } else { taskCode = "LIFELONG"; } this.setData({ currentImg: e.currentTarget.dataset.currentimg, taskCode: taskCode, }); }, switchChange(e) { console.log(e, 1111); this.setData({ isDeductiblePrice: e.detail.value ? 1 : 0, }); }, confirmPay() { wx.showLoading({ title: "正在处理...", mask: true, }); let _this = this; _this.setData({ params: { id: util.getUserId(), code: _this.data.taskCode, isDeductiblePrice: _this.data.isDeductiblePrice == 1 ? 1 : 0, }, }); App._post_form( "member/apiOpenVip", "application/json", _this.data.params, function (result) { if (result.code === 0) { wx.hideLoading(); let money = _this.data.isDeductiblePrice ? _this.data.memberPoints.actualPrice : _this.data.memberPoints.money; if (money == 0) { wx.showModal({ title: "提示", content: "开通会员成功!", showCancel: false, success(res) { if (res.confirm) { wx.navigateBack({ delta: 1, }); } }, }); return; } wx.showActionSheet({ itemList: ["微信支付"], success(res) { if (res.tapIndex === 0) { wx.requestPayment({ timeStamp: result.map.timestamp, nonceStr: result.map.nonce_str, package: "prepay_id=" + result.map.prepay_id, signType: "MD5", paySign: result.map.sign, success: function (res) { if (res) { //此处客户端支付完成,开始查询业务订单支付结果 wx.showLoading({ title: "正在处理...", mask: true, }); App._get( "order/orderInformation", { businessId: _this.data.memberPoints.businessId, businessType: 1, memberId: util.getUserId(), }, function (res) { if (res.code === 0) { wx.hideLoading(); // _this.setData({ // integral: res.data.scoreValue, // }); // _this.popup3.showPopup(); wx.showModal({ title: "提示", content: "开通会员成功!", showCancel: false, success(res) { if (res.confirm) { wx.navigateBack({ delta: 1, }); } }, }); } } ); } }, fail: function (res) { wx.hideLoading(); wx.showToast({ title: "开通失败!", icon: "none", }); }, }); } }, fail(res) {}, }); } else { wx.showModal({ title: "温馨提示", content: result.msg, showCancel: false, }); } } ); this.popup2.hidePopup(); }, _error() { console.log("返回"); this.popup3.hidePopup(); }, _success() { console.log("查看"); this.popup3.hidePopup(); }, _error2() { console.log("返回"); this.popup2.hidePopup(); }, _success2() { console.log("查看"); this.popup2.hidePopup(); }, upgrade() { // this.popup3.showPopup() if (!util.UserLoginStatus()) { return; } if (!this.data.currentImg) { wx.showToast({ icon: "none", title: "请选择会员体系", }); return false; } if (!this.data.agree) { wx.showToast({ title: "请先勾选并同意《青雲慧会员协议》", icon: "none", }); return; } this.getPointDeduction(); this.getTask(); this.popup2.showPopup(); return; }, getTask() { App._get("taskconfig/list", {}, (res) => { if (res.code === 0) { let taskCode; if (this.data.detail.memberState == 0) { if (this.data.currentImg == 1) { taskCode = "ANNUAL_FEE"; } else if (this.data.currentImg == 2) { taskCode = "LIFELONG"; } } else if (this.data.detail.memberState == 1) { taskCode = "MALE_UP"; } this.setData({ taskCode: taskCode, }); } }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.PushVipInfo(); this.height(); this.data.params.id = util.getUserId(); wx.setNavigationBarTitle({ title: "青雲慧", }); this.getVipSelect(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { this.popup2 = this.selectComponent("#popup2"); this.popup3 = this.selectComponent("#popup3"); let that = this let query = wx.createSelectorQuery(); // query.select('#bot-box').boundingClientRect(rect=>{ // let height = rect.height; // console.log(height,'bot-heught') // console.log(rect) // that.setData({ // botCheck: height, // }) // }).exec(); }, toMembershipAgreement() { wx.navigateTo({ url: "/membershipAgreement/index", }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (this.data.bottom === 1) { this.setData({ bottom: 0, }); } this.env() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { if (this.data.bottom === 1) { this.setData({ bottom: 0, }); } }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.setData({ bottom: 1, }); }, checkboxChange(e) { this.setData({ agree: e.detail.value.length > 0, }); }, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, onPageScroll: function (e) { if ( e.scrollTop >= this.data.stHeight.split("px")[0] && this.data.activeTitle == false ) { this.setData({ activeTitle: true, }); } if ( e.scrollTop < this.data.stHeight.split("px")[0] && this.data.activeTitle == true ) { this.setData({ activeTitle: false, }); } }, });