|
|
@@ -75,11 +75,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
- <view v-if="!exchangeShow" @click="exchangeShow=true"
|
|
|
+ <view v-if="!exchangeShow"
|
|
|
class="footer-fixed flex align-center justify-end padding bg-white"
|
|
|
style="padding: 30rpx;;border-top: 1rpx solid #e5e5e5;z-index: 9;">
|
|
|
<button class="cu-btn round text-white theme-bg-color" style="width: 180upx;height: 80upx;"
|
|
|
- @click="exchangeShow=true">兑换</button>
|
|
|
+ @click="exchange">兑换</button>
|
|
|
</view>
|
|
|
|
|
|
<view v-else class="footer-fixed flex align-center justify-between bg-white"
|
|
|
@@ -99,11 +99,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import {authUrl} from '@/common/conf/config.js';
|
|
|
+ import {getUrlParams} from '@/common/utils/utils.js';
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- activityId: '1407016573251153922',
|
|
|
- userId: '1',
|
|
|
+ activityId: '',
|
|
|
+ userId: '',
|
|
|
id: '',
|
|
|
proportion: {},
|
|
|
|
|
|
@@ -124,15 +126,16 @@
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- this.id = options.id
|
|
|
- this.fetchGoodsDetail()
|
|
|
- this.getUsableHotAndPoints()
|
|
|
- this.getAddress()
|
|
|
+ this.id = options.id;
|
|
|
+ this.activityId = options.activityId;
|
|
|
+ this.userId = uni.getStorageSync("userId");
|
|
|
+ this.authorization();
|
|
|
+ this.fetchGoodsDetail();
|
|
|
},
|
|
|
computed:{
|
|
|
- totalCash:{
|
|
|
- get(){
|
|
|
- let total=this.data.cashValue +this.changeCash.hotCash +this.changeCash.pointsCash
|
|
|
+ totalCash: {
|
|
|
+ get() {
|
|
|
+ let total = this.data.cashValue + this.changeCash.hotCash + this.changeCash.pointsCash
|
|
|
return total
|
|
|
}
|
|
|
}
|
|
|
@@ -142,15 +145,13 @@
|
|
|
},
|
|
|
methods: {
|
|
|
getAddress(){
|
|
|
- this.$u.api.user.userAddress({userId:this.userId}).then(res=>{
|
|
|
- this.address=res.records[0]
|
|
|
+ this.$u.api.user.userAddress({userId: this.userId}).then(res => {
|
|
|
+ this.address = res.records[0];
|
|
|
})
|
|
|
},
|
|
|
fetchGoodsDetail() {
|
|
|
- this.$u.api.pointsGoods.list({
|
|
|
- id: this.id
|
|
|
- }).then(res => {
|
|
|
- this.detail = res.records[0]
|
|
|
+ this.$u.api.pointsGoods.list({id: this.id}).then(res => {
|
|
|
+ this.detail = res.records[0];
|
|
|
console.log(this.detail);
|
|
|
})
|
|
|
},
|
|
|
@@ -165,47 +166,46 @@
|
|
|
},
|
|
|
//计数器变化
|
|
|
hotValueChange(item) {
|
|
|
- this.changeCash.hotCash =this.numberMul(item.value,this.proportion.hotProportion)
|
|
|
+ this.changeCash.hotCash = this.numberMul(item.value,this.proportion.hotProportion)
|
|
|
},
|
|
|
- pointsValueChange(item){
|
|
|
- this.changeCash.pointsCash =this.numberMul(item.value,this.proportion.pointsProportion)
|
|
|
+ pointsValueChange(item) {
|
|
|
+ this.changeCash.pointsCash = this.numberMul(item.value,this.proportion.pointsProportion)
|
|
|
},
|
|
|
- async confirm(){
|
|
|
- if (this.$u.test.isEmpty(this.address)||this.$u.test.isEmpty(this.address.id)) {
|
|
|
+ async confirm() {
|
|
|
+ if (this.$u.test.isEmpty(this.address) || this.$u.test.isEmpty(this.address.id)) {
|
|
|
this.$u.toast('请选择地址')
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
-
|
|
|
- if (this.totalCash!=this.detail.cashValue) {
|
|
|
+ if (this.totalCash != this.detail.cashValue) {
|
|
|
uni.showToast({
|
|
|
- title:"总金额不等于商品所需金额",
|
|
|
- duration:3000,
|
|
|
- icon:"none"
|
|
|
+ title: "总金额不等于商品所需金额",
|
|
|
+ duration: 3000,
|
|
|
+ icon: "none"
|
|
|
})
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
- this.data.pointsGoodsId=this.id
|
|
|
- this.data.userId=this.userId
|
|
|
- let res=await this.$u.api.pointsGoods.exchange(this.data)
|
|
|
- if (res.code==400) {
|
|
|
+ this.data.pointsGoodsId = this.id
|
|
|
+ this.data.userId = this.userId
|
|
|
+ let res = await this.$u.api.pointsGoods.exchange(this.data)
|
|
|
+ if (res.code == 400) {
|
|
|
uni.showToast({
|
|
|
- title:res.msg,
|
|
|
- duration:3000,
|
|
|
- icon:"none"
|
|
|
+ title: res.msg,
|
|
|
+ duration: 3000,
|
|
|
+ icon: "none"
|
|
|
})
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
uni.showModal({
|
|
|
- title:"提示",
|
|
|
- content:"兑换成功,可到个人中心查看!",
|
|
|
- confirmColor:"#5a3ee8",
|
|
|
- showCancel:true,
|
|
|
- confirmText:"去查看",
|
|
|
- cancelText:"暂不查看",
|
|
|
+ title: "提示",
|
|
|
+ content: "兑换成功,可到个人中心查看!",
|
|
|
+ confirmColor: "#5a3ee8",
|
|
|
+ showCancel: true,
|
|
|
+ confirmText: "去查看",
|
|
|
+ cancelText: "暂不查看",
|
|
|
success: (res) => {
|
|
|
if (res.confirm) {
|
|
|
uni.navigateTo({
|
|
|
- url:"../mine/pointsGoods/list"
|
|
|
+ url:"/pages/activityList/mine/pointsGoods/list"
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -223,8 +223,35 @@
|
|
|
} catch (e) {}
|
|
|
|
|
|
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
|
|
|
- }
|
|
|
-
|
|
|
+ },
|
|
|
+ exchange() {
|
|
|
+ if (this.$u.test.isEmpty(this.userId)) {
|
|
|
+ let path = "pages/activityList/goods/detail?id=" + this.id + "&activityId=" + this.activityId
|
|
|
+ window.location.href = authUrl(path);
|
|
|
+ } else {
|
|
|
+ this.exchangeShow = true;
|
|
|
+ this.getUsableHotAndPoints()
|
|
|
+ this.getAddress()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async authorization() {
|
|
|
+ let params = getUrlParams(window.location.search);
|
|
|
+ if (!this.$u.test.isEmpty(params.code)) {
|
|
|
+ let res = await this.$u.api.wxInfo.getUserInfo({userCode: params.code});
|
|
|
+ let datas = {
|
|
|
+ nickName: res.nickname,
|
|
|
+ avatar: res.headimgurl,
|
|
|
+ gender: res.sex,
|
|
|
+ openid: res.openid,
|
|
|
+ unionid: res.unionid
|
|
|
+ }
|
|
|
+ let result = await this.$u.api.user.login(datas);
|
|
|
+ if (result) {
|
|
|
+ this.userId = result.id;
|
|
|
+ uni.setStorageSync("userId", result.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
}
|
|
|
</script>
|