|
|
@@ -4,7 +4,7 @@
|
|
|
<!-- 导航栏 :leftIconColor="!isTop ? '#fff' : '#000'"-->
|
|
|
<u-navbar :placeholder="true" autoBack>
|
|
|
<view slot="center">
|
|
|
- <view class="center" style="background-color: #fff;">商品详情</view>
|
|
|
+ <view class="center navbar-title" style="background-color: #fff;">商品详情</view>
|
|
|
</view>
|
|
|
</u-navbar>
|
|
|
<!-- 主图 -->
|
|
|
@@ -43,30 +43,30 @@
|
|
|
<!-- 第二行text -->
|
|
|
<view class="seconedRow">
|
|
|
<view class="specClass">
|
|
|
- <view v-if="!selectedObj"
|
|
|
- style="display: flex;align-items: center;justify-content:space-between;width: 100%;">
|
|
|
- <view style="color: #666666;">选择</view>
|
|
|
- <image style="width: 28rpx;height: 28rpx;" @click="selectProductShowFun"
|
|
|
- src="@/static/points/Keyboard_arrow_rifht.png" mode=""></image>
|
|
|
- </view>
|
|
|
- <view v-if="selectedObj"
|
|
|
- style="display: flex;align-items: center;justify-content: space-between;width: 100%;">
|
|
|
+ <view style="display: flex;align-items: center;justify-content: space-between;width: 100%;">
|
|
|
<view style="display: flex;align-items: center;">
|
|
|
<text style="color: #666666;">规格</text>
|
|
|
- <ImageItem class="imgClass" :src="$globalData.publicUrl + selectedObj.image" />
|
|
|
+ <ImageItem v-if="selectedObj" class="imgClass" :src="$globalData.publicUrl + selectedObj.image" />
|
|
|
</view>
|
|
|
- <view style="display: flex;align-items: center;">
|
|
|
- <text style="color: #666666;margin-right: 8rpx;">已选:{{ selectedObj.specValueText }}</text>
|
|
|
- <image style="width: 28rpx;height: 28rpx;" @click="selectProductShowFun"
|
|
|
- src="@/static/points/Keyboard_arrow_rifht.png" mode=""></image>
|
|
|
+ <view style="display: flex;align-items: center;position: relative;">
|
|
|
+ <text v-if="selectedObj" style="color: #666666;margin-right: 30rpx;">已选:{{
|
|
|
+ selectedObj.specValueText }}</text>
|
|
|
+ <text v-else style="color: #999;margin-right: 30rpx;">选择商品</text>
|
|
|
+ <span style="position: absolute;right: 0;top: 1rpx;">
|
|
|
+ <image style="width: 28rpx;height: 28rpx;" @click="selectProductShowFun"
|
|
|
+ src="@/static/points/Keyboard_arrow_rifht.png" mode=""></image>
|
|
|
+ </span>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
<view class="arriveAddressClass">
|
|
|
<text style="color: #666666;margin-right: 24rpx;">送至</text>
|
|
|
- <text>山西省太原市万柏林区</text>
|
|
|
- <span style="position: absolute;right: 0;">
|
|
|
+ <text v-if="defaultAddress"
|
|
|
+ style="width: 520rpx;white-space:nowrap;overflow: hidden;text-overflow: ellipsis;">
|
|
|
+ {{ defaultAddress.address }}</text>
|
|
|
+ <text v-else style="color: #999;position: absolute;right: 30rpx;">添加收货地址</text>
|
|
|
+ <span style="position: absolute;right: 0;top: 1rpx;">
|
|
|
<image style="width: 28rpx;height: 28rpx;" @click="addressSelectFun"
|
|
|
src="@/static/points/Keyboard_arrow_rifht.png" mode=""></image>
|
|
|
</span>
|
|
|
@@ -134,9 +134,10 @@
|
|
|
<u-popup :show="redemptionRulesShowPopup" mode="bottom" @close="redemptionRulesShowPopup = false" round="20">
|
|
|
<RedemptionRules ref="redemptionRulesRef"></RedemptionRules>
|
|
|
</u-popup>
|
|
|
- <u-popup :show="selectProductShowPopup" mode="bottom" round="10">
|
|
|
- <SelectProduct :params="params" ref="selectProductRef" @redeemNowFun="redeemNowFun"
|
|
|
- @closeSelectProduct="closeSelectProduct"></SelectProduct>
|
|
|
+ <u-popup :z-index="99" :show="selectProductShowPopup" mode="bottom" round="10">
|
|
|
+ <SelectProduct :params="params" ref="selectProductRef" :defaultAddress="defaultAddress"
|
|
|
+ @redeemNowFun="redeemNowFun" @closeSelectProduct="closeSelectProduct">
|
|
|
+ </SelectProduct>
|
|
|
</u-popup>
|
|
|
|
|
|
</scroll-view>
|
|
|
@@ -152,6 +153,13 @@ import ImageItem from "@/components/swiper/components/image.vue";
|
|
|
import RedemptionRules from "./components/redemptionRules.vue";
|
|
|
import SelectProduct from "./components/selectProduct.vue";
|
|
|
import { productGetById, productOrderCreate } from '@/api/points'
|
|
|
+import { getAddrList, } from '@/api/address';
|
|
|
+import {
|
|
|
+ getInfo,
|
|
|
+ payoff,
|
|
|
+ pay,
|
|
|
+ getSignature,
|
|
|
+} from '@/api/index.js';
|
|
|
|
|
|
export default {
|
|
|
components: { ImageItem, RedemptionRules, SelectProduct },
|
|
|
@@ -167,19 +175,35 @@ export default {
|
|
|
{ name: '7天无理由退换', icon: '/static/points/Group2.png', isShow: false },
|
|
|
{ name: '破损包退换', icon: '/static/points/return7.png', isShow: false },
|
|
|
],
|
|
|
- selectedObj: null
|
|
|
+ selectedObj: null,
|
|
|
+ defaultAddress: null,
|
|
|
+ selectPayMeth: null, //1 微信支付 2 余额
|
|
|
+ orderRemarks: null,
|
|
|
+ addressList: [],
|
|
|
+ dBalance: 0.00,
|
|
|
|
|
|
|
|
|
}
|
|
|
},
|
|
|
- onLoad(id) {
|
|
|
- if (id) {
|
|
|
- this.productGetByIdFun(id)
|
|
|
+ onLoad(data) {
|
|
|
+ console.log(data, '66666')
|
|
|
+ if (data.id) {
|
|
|
+ this.productGetByIdFun(data.id)
|
|
|
+ this.getAddrListFun()
|
|
|
+ this.getinfo()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
onShow() {
|
|
|
-
|
|
|
+ //选择地址后传回的地址id
|
|
|
+ if (this.selectedAddressId) {
|
|
|
+ if (this.selectedAddressId !== this.defaultAddress.id) {
|
|
|
+ this.defaultAddress = this.addressList.find(item => {
|
|
|
+ if (item.id == this.selectedAddressId)
|
|
|
+ return item
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
onPageScroll(e) {
|
|
|
//console.log("滚动距离为:" + e.scrollTop);
|
|
|
@@ -190,9 +214,36 @@ export default {
|
|
|
handleContentScroll(e) {
|
|
|
this.isTop = e.detail.scrollTop > 0
|
|
|
},
|
|
|
+ //账户余额
|
|
|
+ getinfo() {
|
|
|
+ getInfo().then(res => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ console.log(res, 'res6666')
|
|
|
+ this.dBalance = res.data.data.dBalance.toFixed(2)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //查询默认地址
|
|
|
+ getAddrListFun() {
|
|
|
+ let params = {
|
|
|
+ current: 1,
|
|
|
+ size: 100,
|
|
|
+ openId: uni.getStorageSync('wx_copenid'),
|
|
|
+ }
|
|
|
+ getAddrList(params).then(res => {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ this.addressList = res.data.data
|
|
|
+ this.defaultAddress = res.data.data.find(item => {
|
|
|
+ if (item.type == 1)
|
|
|
+ return item
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
//查询商品详情
|
|
|
productGetByIdFun(id) {
|
|
|
- productGetById({ id: 19 }).then(res => {
|
|
|
+ productGetById({ id: id }).then(res => {
|
|
|
if (res.data.code === 200) {
|
|
|
this.params = Object.assign({}, res.data.data)
|
|
|
//this.selectedObj = this.params.specComboVOList[0]
|
|
|
@@ -215,95 +266,195 @@ export default {
|
|
|
this.redemptionRulesShowPopup = true
|
|
|
},
|
|
|
//立即兑换
|
|
|
- redeemNowFun(selectedObj) {
|
|
|
+ redeemNowFun(selectedObj, selectPayMeth, orderRemarks) {
|
|
|
if (selectedObj) this.selectedObj = selectedObj
|
|
|
+ if (selectPayMeth) this.selectPayMeth = selectPayMeth
|
|
|
+ if (orderRemarks) this.orderRemarks = orderRemarks
|
|
|
+
|
|
|
+ // if (this.remainingTime == 0) {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '订单已过期',
|
|
|
+ // icon: 'none'
|
|
|
+ // })
|
|
|
+ // return;
|
|
|
+ //
|
|
|
+
|
|
|
if (this.selectedObj) {
|
|
|
+ if (this.selectPayMeth == null) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请选择支付方式',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ } else if (this.selectPayMeth == 1) {
|
|
|
+ //微信支付
|
|
|
+ this.weixinPay()
|
|
|
+ } else if (this.selectPayMeth == 2) {
|
|
|
+ //余额支付
|
|
|
+ this.nowYuyue()
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.selectProductShowPopup = true
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.selectProductRef.onShowFun(this.selectedObj, this.orderRemarks, this.selectPayMeth)
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ //微信支付
|
|
|
+ weixinPay() {
|
|
|
+ let params = {}
|
|
|
+ params.openId = uni.getStorageSync('wx_copenid');//用户openId
|
|
|
+ params.addressId = this.defaultAddress.id;//地址ID
|
|
|
+ params.productId = this.params.id;
|
|
|
+ params.name = this.params.name;
|
|
|
+ params.productMainImage = this.params.productMainImage;
|
|
|
+ params.skuId = this.selectedObj.index; //选中的SKU ID
|
|
|
+ params.specNameValueLis = this.selectedObj.specNameValueList; // SKU列表(规格组合明细)
|
|
|
+ params.quantity = 1; //购买数量
|
|
|
+ params.payType = Number(this.selectPayMeth);//支付方式:1微信支付 2账户余额
|
|
|
+ params.freightAmount = this.params.freight; //运费
|
|
|
+ params.totalAmount = this.selectedObj.originPrice;// 总金额
|
|
|
+ params.payAmount = this.selectedObj.priceMoney;// 支付金额
|
|
|
+ params.pointsUsed = this.selectedObj.pricePoint;// 使用的积分
|
|
|
+ params.buyerRemark = this.orderRemarks;//买家备注信息
|
|
|
+ console.log(params, 'params')
|
|
|
+ productOrderCreate(params).then(res => {
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ return
|
|
|
+ let url = 'https://test.baoxianzhanggui.com/fragrance/'
|
|
|
+ payoff(params).then(res => {
|
|
|
+ let payConfig = JSON.parse(res.data.data)
|
|
|
+ getSignature(url).then(res => {
|
|
|
+ this.wxconfig = res.data
|
|
|
+ wx.config({
|
|
|
+ beta: true,
|
|
|
+ debug: false,
|
|
|
+ appId: this.wxconfig.appId, // 公众号ID
|
|
|
+ // appId: uni.getAppBaseInfo().host.appId, // 公众号ID
|
|
|
+ timestamp: this.wxconfig.timestamp, // 时间戳,自1970年以来的秒数
|
|
|
+ nonceStr: this.wxconfig.nonceStr, // 随机串
|
|
|
+ signature: this.wxconfig.sign, // 微信签名方式
|
|
|
+ jsApiList: ['getBrandWCPayRequest']
|
|
|
+ });
|
|
|
+ var vm = this
|
|
|
+ wx.invoke('getBrandWCPayRequest',
|
|
|
+ // 下面参数内容都是后台返回的
|
|
|
+ {
|
|
|
+ 'appId': payConfig.appid, // 公众号名称,由商户传入
|
|
|
+ 'timeStamp': payConfig.timeStamp, // 时间戳
|
|
|
+ 'nonceStr': payConfig.nonceStr, // 随机串
|
|
|
+ 'package': payConfig.package, // 预支付id
|
|
|
+ 'signType': payConfig.signType, // 微信签名方式
|
|
|
+ 'paySign': payConfig.paySign, // 微信签名
|
|
|
+ },
|
|
|
+ function (res) {
|
|
|
+ // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
+
|
|
|
+ // JSON.stringify(res);
|
|
|
+ if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/points/productDetails/paymentSuccessful'
|
|
|
+ });
|
|
|
+ } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
|
|
|
+ uni.showToast({
|
|
|
+ title: '已取消支付',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/points/productDetails/pendingPayment'
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ alert('付款失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //账号余额支付
|
|
|
+ nowYuyue() {
|
|
|
+ if (parseInt(this.dBalance) < parseInt(this.selectedObj.priceMoney)) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '账户余额不足',
|
|
|
+ content: '请充值',
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: 'pages/my/pay?name=充值'
|
|
|
+ })
|
|
|
+ } else if (res.cancel) { }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
let params = {}
|
|
|
- ////用户openId
|
|
|
- params.openId = uni.getStorageSync('wx_copenid');
|
|
|
- //地址ID
|
|
|
- params.addressId = '11';
|
|
|
+ params.openId = uni.getStorageSync('wx_copenid');//用户openId
|
|
|
+ params.addressId = this.defaultAddress.id;//地址ID
|
|
|
params.productId = this.params.id;
|
|
|
params.name = this.params.name;
|
|
|
params.productMainImage = this.params.productMainImage;
|
|
|
- //选中的SKU ID
|
|
|
- params.skuId = this.selectedObj.index;
|
|
|
- // SKU列表(规格组合明细)
|
|
|
- params.specNameValueLis = this.selectedObj.specNameValueList;
|
|
|
- ////购买数量
|
|
|
- params.quantity = 1;
|
|
|
- ////支付方式:1微信支付 2账户余额
|
|
|
- params.payType = Number(this.$refs.selectProductRef.selectPayMeth);
|
|
|
- //运费
|
|
|
- params.freightAmount = this.params.freight;
|
|
|
- // 总金额
|
|
|
- params.totalAmount = this.selectedObj.originPrice;
|
|
|
- // 支付金额
|
|
|
- params.payAmount = this.selectedObj.priceMoney;
|
|
|
- // 使用的积分
|
|
|
- params.pointsUsed = this.selectedObj.pricePoint;
|
|
|
- //买家备注信息
|
|
|
- params.buyerRemark = this.$refs.selectProductRef.orderRemarks;
|
|
|
- uni.navigateTo({
|
|
|
- url: '/points/productDetails/paymentSuccessful'
|
|
|
- });
|
|
|
+ params.skuId = this.selectedObj.index; //选中的SKU ID
|
|
|
+ params.specNameValueLis = this.selectedObj.specNameValueList; // SKU列表(规格组合明细)
|
|
|
+ params.quantity = 1; //购买数量
|
|
|
+ params.payType = Number(this.selectPayMeth);//支付方式:1微信支付 2账户余额
|
|
|
+ params.freightAmount = this.params.freight; //运费
|
|
|
+ params.totalAmount = this.selectedObj.originPrice;// 总金额
|
|
|
+ params.payAmount = this.selectedObj.priceMoney;// 支付金额
|
|
|
+ params.pointsUsed = this.selectedObj.pricePoint;// 使用的积分
|
|
|
+ params.buyerRemark = this.orderRemarks;//买家备注信息
|
|
|
console.log(params, 'params')
|
|
|
- return
|
|
|
-
|
|
|
-
|
|
|
productOrderCreate(params).then(res => {
|
|
|
-
|
|
|
- uni.requestPayment({
|
|
|
- "provider": "wxpay",
|
|
|
- "orderInfo": {},
|
|
|
- success(res) { },
|
|
|
- fail(e) { }
|
|
|
- })
|
|
|
- // uni.navigateTo({
|
|
|
- // url: '/points/productDetails/paymentSuccessful'
|
|
|
- // });
|
|
|
+
|
|
|
+
|
|
|
})
|
|
|
+ return
|
|
|
+ var data = {
|
|
|
+ cId: this.details.cId,
|
|
|
+ payType: this.selectedPayment,
|
|
|
+ couponReceiveId: this.couponReceiveId,
|
|
|
+ preferential: this.preferential, //优惠金额
|
|
|
+ totalPrice: this.totalPrice, //总金额
|
|
|
+ }
|
|
|
+ payoff(data).then(res => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/points/productDetails/paymentSuccessful'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'error',
|
|
|
+ title: res.data.msg,
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- this.selectProductShowPopup = true
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.selectProductRef.onShowFun(this.selectedObj)
|
|
|
- });
|
|
|
+ })
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
//打开选择商品页
|
|
|
selectProductShowFun() {
|
|
|
this.selectProductShowPopup = true
|
|
|
this.$nextTick(() => {
|
|
|
- this.$refs.selectProductRef.onShowFun(this.selectedObj)
|
|
|
+ this.$refs.selectProductRef.onShowFun(this.selectedObj, this.orderRemarks, this.selectPayMeth)
|
|
|
});
|
|
|
},
|
|
|
//关闭选择商品页
|
|
|
- closeSelectProduct(selectedObj) {
|
|
|
- if (selectedObj) {
|
|
|
- this.selectedObj = selectedObj
|
|
|
- }
|
|
|
+ closeSelectProduct(selectedObj, selectPayMeth, orderRemarks) {
|
|
|
+ if (selectedObj) this.selectedObj = selectedObj
|
|
|
+ if (selectPayMeth) this.selectPayMeth = selectPayMeth
|
|
|
+ if (orderRemarks) this.orderRemarks = orderRemarks
|
|
|
this.selectProductShowPopup = false
|
|
|
},
|
|
|
- //去我的地址页面
|
|
|
+ //去我的地址页面 /points/productDetails/addressManagement
|
|
|
addressSelectFun() {
|
|
|
uni.navigateTo({
|
|
|
- url: '/points/productDetails/addressManagement'
|
|
|
+ url: `/pages/address/index?selectedAddressId=${this.defaultAddress.id}`
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- //导航栏返回按钮
|
|
|
- leftClick() {
|
|
|
- uni.navigateTo({
|
|
|
- url: `pages/member/center`
|
|
|
- })
|
|
|
- // /let str = uni.$u.queryParams(params);
|
|
|
- // uni.navigateTo({
|
|
|
- // url: `/packageA/pages/shop/coupon/couponDetail${str}`
|
|
|
- // });
|
|
|
- },
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
@@ -437,6 +588,7 @@ export default {
|
|
|
.arriveAddressClass {
|
|
|
margin-top: 32rpx;
|
|
|
position: relative;
|
|
|
+ display: flex;
|
|
|
}
|
|
|
|
|
|
.addressTextClass {
|