123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
- // 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,
- });
- }
- },
- });
|