|
- // pages/spellDetail/index.js
- var config = require("../../../config/config.js");
- const Http = require("../../../utils/HttpBasics");
- const imgurl = require("../../../utils/imgurl");
- const { spellStatus } = require("../../../utils/spell");
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- tuanzhang: imgurl.tuanzhang.url,
- spellBg: imgurl.spellBg.url,
- position: imgurl.position.url,
- close03: imgurl.close03.url,
- home: imgurl.wmhome.url,
- paramData: null,
- data: null,
- showErr: false,
- showAlert: false,
- remainingPoints:0
- },
- getUserInfo: function () {
- let that = this;
- // 获取用户信息
- Http.get({
- url: config.api.getScore,
- data: {}
- })
- .then(res => {
- console.log(res)
- that.setData({
- remainingPoints: Number(res.data.credit) - Number(that.data.data.creditPrice),
- userInfo:res.data,
- nickName: res.data.nickName,
- avatarUrl: res.data.avatarUrl
- })
- })
- },
- gotoIndex() {
- wx.reLaunch({
- url: '/pages/index/index',
- })
- },
- gotoSearch() {
- wx.navigateTo({
- url: `/pages/spellGroup/spellGroup`,
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- paramData: options
- })
- this.getDetail(options.couponChannelId);
-
- // 关闭来自于左上角的分享
- wx.hideShareMenu()
- },
- gotoPay() {
- let that = this;
- wx.showLoading({
- title: '订单提交中...',
- })
- //操作人类型 1:C端用户,2:A端会员,3:B端用户,4:A端用户
- let param={
- cuserId:that.data.userInfo.id,//用户id
- operatorType:1,//操作人类型
- creditType: 11,//积分类型-积分兑换
- spend:this.data.data.credit,//积分数值
- couponId: this.data.data.couponId
- }
- Http.post({
- url: config.api.addIntegral,
- data: param
- })
- .then(res => {
- wx.hideLoading()
- /// End payment --------
- })
- .catch(err => {
- wx.showToast({
- title: err.message,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- })
- },
- /**
- * 获取券详情信息
- */
- getDetail(couponChannelId) {
- let that = this;
- Http.get({
- url: config.api.couponDetail,
- data: {
- couponChannelId: couponChannelId
- }
- }).then(res => {
- wx.stopPullDownRefresh();
- that.getUserInfo()
- let data = res.data;
- that.setData({
- data
- });
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.getDetail(this.data.paramData.couponChannelId);
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- }
- })
|