123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api');
- var user = require('../../../utils/user.js');
- var app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- buyType: '2', //1月卡 2年卡
- oldPrice: '199',
- actualPrice: '199',
- typeList: [{
- url:'https://jzmall.lifejingzhi.com/file/jzmall/weixin/memberCard-1229/member-type-1.png',
- type: '2',
- name: '年卡',
- price: '199',
- typeName: '年',
- oldPrice: '199'
- },
- {
- url:'https://jzmall.lifejingzhi.com/file/jzmall/weixin/memberCard-1229/member-type-2.png',
- type: '1',
- name: '月卡',
- price: '19',
- typeName: '月',
- oldPrice: '19'
- },
- {
- url:'https://jzmall.lifejingzhi.com/file/jzmall/weixin/memberCard-1229/member-type-3.png',
- type: '3',
- name: '年卡',
- },
- ],
- memberUserInfo:{
- nickName: '用户',
- avatarUrl: '/static/images/new/icon-user.png',
- level:'0'
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- switchType(e) {
- let type = e.currentTarget.dataset.type;
- let actualPrice = e.currentTarget.dataset.price;
- this.setData({
- buyType: type,
- actualPrice: actualPrice,
- oldPrice: type == '2' ? '199' : '19'
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.setData({
- memberUserInfo:app.globalData.memberUserInfo
- });
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- payNow() {
- let that=this
- wx.showModal({
- title: "会员开卡确认",
- content: "会员权益卡,购买后无法退换,确定购买?",
- showCancel: true,
- cancelText: "取消",
- cancelColor: "#000",
- confirmText: "购买",
- confirmColor: "#0f0",
- success: function (res) {
- if (res.confirm) {
- that.memberSubmit();
- }
- }
- })
- },
- memberSubmit() {
-
- let orderInfo = {
- userId: app.globalData.userInfo.id,
- memberType: this.data.buyType,
- };
- util.request(api.memberSubmit, orderInfo, 'POST').then(res => {
- if (res.errno === 0) {
- let orderId = res.data.memberOrderNo;
- this.prepayMember(orderId);
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- },
- prepayMember(orderId) {
- util.request(api.prepayMember, {
- memberOrderNo: orderId
- }, 'POST').then(res => {
- if (res.errno === 0) {
- let payParam = res.data;
- console.log("支付过程开始");
- wx.requestPayment({
- 'timeStamp': payParam.timeStamp,
- 'nonceStr': payParam.nonceStr,
- 'package': payParam.packageValue,
- 'signType': payParam.signType,
- 'paySign': payParam.paySign,
- 'success': res => {
- console.log("支付过程成功");
- wx.redirectTo({
- url: '/pages/member/becomeMember/becomeMember',
- })
- },
- 'fail': res => {
- console.log("支付过程失败");
- util.showErrorToast('支付失败');
- },
- 'complete': function (res) {
- console.log("支付过程结束")
- }
- });
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- },
- goConvert() {
- wx.navigateTo({
- url: '/pages/member/memberConvert/memberConvert',
- })
- },
- })
|