Commit 31c4bdb4 authored by wangxuelai's avatar wangxuelai

''

parent 6345f462
......@@ -11,7 +11,8 @@ const apis = {
goodsList: `${api}student/integral/goods`,
goodsDetail: `${api}student/integral/goods`,
goodsDetail: `${api}student/integral/goods`,
exchangesGoodsDetail: `${api}student/integral/exchanges`
exchangesGoodsDetail: `${api}student/integral/exchanges`,
integralExchange: `${api}student/integral/exchange`
},
common: {
consumerSession: `${api}common/login`,
......
......@@ -41,9 +41,19 @@ function exchangesGoodsDetail (data) {
errorresolve: 1,
})
}
function integralExchange (data) {
return wxRequest({
role: '2c',
url: apis.customer.integral.integralExchange,
data,
method: 'POST',
errorresolve: 1,
})
}
export {
myIntegral,
goodsList,
exchangesGoodsDetail,
goodsDetail
goodsDetail,
integralExchange
}
\ No newline at end of file
......@@ -216,5 +216,16 @@ Page({
}).catch((err) => {
});
},
goExchangeList () {
wx.navigateTo({
url: `/src/pages/pointsexchangerecord/index?sid=${this.data.sid}`,
})
},
goGoodDetail (e) {
const {id} = e.currentTarget.dataset;
wx.navigateTo({
url: `/src/pages/scoreprodetail/index?sid=${this.data.sid}&gid=${id}`,
})
}
})
\ No newline at end of file
......@@ -12,7 +12,7 @@
<image class="btnicon" src="{{localImageRoot}}2c/mall/earnscore.png?{{imageVersion}}" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload=""></image>
<text class="btnname" selectable="false" space="false" decode="false">赚积分</text>
</view>
<view class="btn btnb" hover-class="none" hover-stop-propagation="false">
<view class="btn btnb" hover-class="none" hover-stop-propagation="false" bindtap="goExchangeList">
<image class="btnicon" src="{{localImageRoot}}2c/mall/exchangerecord.png?{{imageVersion}}" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload=""></image>
<text class="btnname" selectable="false" space="false" decode="false">兑换记录</text>
</view>
......@@ -24,7 +24,7 @@
<text class="areaname" selectable="false" space="false" decode="false">精选奖品</text>
</view>
<view class="prizecontent" hover-class="none" hover-stop-propagation="false" wx:if="{{goodsList.length > 0}}">
<view class="prizecardbox {{(index+1)%2 == 1 ? 'odd' : 'even'}}" hover-class="none" hover-stop-propagation="false" wx:for="{{goodsList}}" wx:key="{{index}}">
<view class="prizecardbox {{(index+1)%2 == 1 ? 'odd' : 'even'}}" hover-class="none" hover-stop-propagation="false" bindtap="goGoodDetail" data-id="{{item.id}}" wx:for="{{goodsList}}" wx:key="{{index}}">
<view class="prizecard" hover-class="none" hover-stop-propagation="false">
<image class="prizeimage" src="{{filter.imagify(item.cover)}}" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload=""></image>
<view class="prizename" hover-class="none" hover-stop-propagation="false">{{item.title}}</view>
......@@ -40,7 +40,7 @@
<text class="areaname" selectable="false" space="false" decode="false">优惠卡券</text>
</view>
<view class="couponcontent" hover-class="none" hover-stop-propagation="false" wx:if="{{couponList.length > 0}}">
<view class="couponcardbox {{(index+1)%2 == 1 ? 'odd' : 'even'}}" hover-class="none" hover-stop-propagation="false" wx:for="{{couponList}}" wx:key="{{index}}">
<view class="couponcardbox {{(index+1)%2 == 1 ? 'odd' : 'even'}}" hover-class="none" hover-stop-propagation="false" bindtap="goGoodDetail" data-id="{{item.id}}" wx:for="{{couponList}}" wx:key="{{index}}">
<view class="couponcard" hover-class="none" hover-stop-propagation="false">
<view class="couponitem" hover-class="none" hover-stop-propagation="false">
<image class="couponbg" src="{{localImageRoot}}2c/mall/cardbgblue.png?{{imageVersion}}" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload=""></image>
......
import {
exchangesGoodsDetail,
goodsDetail,
myIntegral
myIntegral,
integralExchange
} from '../../../service/customer/integral.js';
var app = getApp();
Page({
......@@ -17,6 +18,7 @@ Page({
gid: 0,
params: {},
balance: 0,
submitting: false
},
/**
......@@ -122,5 +124,51 @@ Page({
})
}
})
},
buy () {
const that = this;
if (that.data.params.status == 2) {
wx.showToast({
title: '商品已下架'
})
return;
}
if (that.data.params.price > that.data.balance) {
wx.showModal({
title: '提示',
content: `积分不足,邀请好友赚取更多积分吧~`,
confirmColor: '#FFA719',
confirmText: '知道了',
showCancel: false
})
return;
}
wx.showModal({
title: '提示',
content: `需要消耗${that.data.params.price}积分`,
confirmColor: '#FFA719',
confirmText: '兑换',
success (res) {
if (res.confirm) {
if (that.data.submitting) {
return
}
that.data.submitting = true;
integralExchange({
good_id: that.data.gid
}).then((res) => {
const {code, data} = res;
that.data.submitting = false;
if (code == 200) {
that.setData({
balance: Number(that.data.balance) - Number(that.data.params.price)
})
}
}).catch(() => {
that.data.submitting = false;
})
}
}
})
}
})
\ No newline at end of file
......@@ -45,6 +45,6 @@
<text class="linecost" selectable="false" space="false" decode="false">{{balance}}积分</text>
</view>
</view>
<view class="buyboxright" hover-class="none" hover-stop-propagation="false">立即兑换</view>
<view class="buyboxright" hover-class="none" hover-stop-propagation="false" bindtap="buy">{{params.status == 1? '立即兑换' : '已下架'}}</view>
</view>
</view>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment