分享朋友圈调整
This commit is contained in:
@@ -9,16 +9,20 @@ Page({
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
disabled : true,//按钮
|
||||
disabled : true, //按钮
|
||||
skuId : '',
|
||||
goodsQty : '', // 产品数量
|
||||
address : '', // 地址
|
||||
addressId : '', // 地址id
|
||||
goodskData : '', // 数据
|
||||
amount : '', // 商品总金额
|
||||
total : '', // 支付金额
|
||||
freight : '', // 运费
|
||||
weight : '', // 重量
|
||||
goodsQty : '', // 产品数量
|
||||
address : '', // 地址
|
||||
goodskData : '', // 数据
|
||||
amount : '', // 商品总金额
|
||||
total : '', // 支付金额
|
||||
freight : '', // 运费
|
||||
weight : '', // 重量
|
||||
distribution : [
|
||||
{ type: 0, title: "快递" },
|
||||
{ type: 1, title: "自提" },
|
||||
],
|
||||
distributionIndex: 0
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -32,30 +36,43 @@ Page({
|
||||
// 获取商品下单信息
|
||||
this.placeInfo(options.skuId, options.qty);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
* 配送方式选择
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
distributionChange(e){
|
||||
if(e.detail.value === this.data.distributionIndex) return
|
||||
this.setData({
|
||||
distributionIndex: e.detail.value
|
||||
})
|
||||
this.placeInfo(this.data.skuId, this.data.goodsQty);
|
||||
},
|
||||
/**
|
||||
* 商品下单信息
|
||||
*/
|
||||
placeInfo(skuid, qty) {
|
||||
placeInfo(skuid, qty, type) {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
mask : true
|
||||
})
|
||||
wx.$api.mall.place({
|
||||
goods_sku_id:skuid,
|
||||
qty: qty,
|
||||
address_id: this.data.addressId
|
||||
goods_sku_id : skuid,
|
||||
qty : qty,
|
||||
address_id : this.data.address.address_id || '',
|
||||
delivery_type: this.data.distributionIndex
|
||||
}).then(res => {
|
||||
if(type != 'chooseAdd'){
|
||||
this.setData({
|
||||
address: res.data.address,
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
address : res.data.address,
|
||||
addressId : res.data.address.address_id,
|
||||
goodskData: res.data.detail,
|
||||
amount : res.data.amount,
|
||||
total : res.data.total,
|
||||
freight : res.data.freight,
|
||||
weight : res.data.weight
|
||||
})
|
||||
wx.hideLoading()
|
||||
}).catch(err =>{})
|
||||
},
|
||||
|
||||
@@ -70,16 +87,13 @@ Page({
|
||||
wx.$api.mall.placeTrue({
|
||||
goods_sku_id : this.data.skuId,
|
||||
qty : this.data.goodsQty,
|
||||
address_id : this.data.addressId
|
||||
address_id : this.data.address.address_id,
|
||||
delivery_type : this.data.distributionIndex
|
||||
}).then(res => {
|
||||
|
||||
console.log(res)
|
||||
|
||||
wx.redirectTo({
|
||||
url: '/pages/pay/index?params=' + encodeURIComponent(JSON.stringify(res.data))
|
||||
})
|
||||
}).catch(() =>{}).finally(() => {
|
||||
wx.hideLoading()
|
||||
})
|
||||
}).catch(() =>{}).finally(() => {})
|
||||
},
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
<!-- 地址 -->
|
||||
<view class="address">
|
||||
<navigator hover-class="none" url="/pages/site/index?type=goodsAddress" class="address-cont" wx:if="{{address}}">
|
||||
<view class="address" wx:if="{{distributionIndex == 0}}">
|
||||
<navigator hover-class="none" url="/pages/site/index?type=goodsAddress&skuid={{skuId}}&qty={{goodsQty}}" class="address-cont" wx:if="{{address}}">
|
||||
<view class="address-top">
|
||||
<view class="address-area">
|
||||
<image class="address-icon" src="/static/icons/address.png" mode="widthFix"></image>{{address.province.name}}{{address.city.name}}
|
||||
@@ -13,7 +13,7 @@
|
||||
<image class="address-arrow" src="/static/icons/orderArrow.png"></image>
|
||||
</navigator>
|
||||
<view class="address-add" wx:else>
|
||||
<navigator hover-class="none" url="/pages/site/index?type=goodsAddress" class="address-go">新增收货地址 +</navigator>
|
||||
<navigator hover-class="none" url="/pages/site/index?type=goodsAddress&skuid={{skuId}}&qty={{goodsQty}}" class="address-go">新增收货地址 +</navigator>
|
||||
</view>
|
||||
<image class="address-img" src="/static/imgs/address.png" mode="widthFix"></image>
|
||||
</view>
|
||||
@@ -34,9 +34,19 @@
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 规格 -->
|
||||
<!-- 配送方式 -->
|
||||
<view class="label">
|
||||
<view class="label-item">
|
||||
<view class="label-name">配送方式</view>
|
||||
<picker range="{{distribution}}" range-key="title" class="label-picker" value="{{distributionIndex}}" bindchange="distributionChange">
|
||||
<view class="label-picker-val">{{distribution[distributionIndex].title}}<image class="label-picker-icon" src="/static/icons/arrow_more.png"></image></view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 规格 -->
|
||||
<view class="label">
|
||||
<view class="label-item" wx:if="{{distributionIndex == 0}}">
|
||||
<view class="label-name">快递</view>
|
||||
<view class="label-text">{{freight == 0 ? '免邮' : freight + '元'}}</view>
|
||||
</view>
|
||||
|
||||
@@ -10,6 +10,7 @@ page {
|
||||
border-radius: 15rpx;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.address-arrow {
|
||||
@@ -77,7 +78,7 @@ page {
|
||||
|
||||
.list-goods {
|
||||
background-color: #FFFFFF;
|
||||
margin: 30rpx 0;
|
||||
margin: 0 0 30rpx 0;
|
||||
display: flex;
|
||||
padding: 30rpx;
|
||||
border-radius: 15rpx;
|
||||
@@ -124,6 +125,7 @@ page {
|
||||
border-radius: 15rpx;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.label-item {
|
||||
@@ -149,6 +151,10 @@ page {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.label-picker{ width: 70%; }
|
||||
.label-picker-val{ text-align: right; display: flex; align-items: center; justify-content: flex-end;}
|
||||
.label-picker-icon{ width: 24rpx; height: 24rpx; margin-left: 10rpx; }
|
||||
|
||||
|
||||
/*checkbox选中后样式 */
|
||||
.label-text-checkbox {
|
||||
|
||||
@@ -32,8 +32,8 @@ Page({
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
goodsId: options.id,
|
||||
invite : options.invite || ''
|
||||
})
|
||||
getApp().globalData.invite = options.invite || ''
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -44,27 +44,95 @@ Page({
|
||||
this.goodsInfo();
|
||||
},
|
||||
|
||||
/**
|
||||
* 输入产品数量
|
||||
*/
|
||||
goodsNumberInput(e){
|
||||
let inventory = this.data.selectSkusValues.stock
|
||||
if(inventory < e.detail.value ){
|
||||
wx.showToast({
|
||||
title: '超出库存数量',
|
||||
icon : 'none',
|
||||
})
|
||||
this.setData({
|
||||
qtyNumber: Math.min(inventory, e.detail.value)
|
||||
})
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
qtyNumber: e.detail.value
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 离开产品数量
|
||||
*/
|
||||
goodsNumberBlur(e){
|
||||
let { value } = e.detail
|
||||
if(value == '' || value <= 0){
|
||||
this.setData({
|
||||
qtyNumber: 1
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 商品详情
|
||||
*/
|
||||
goodsInfo() {
|
||||
// 因分享朋友圈启动时未挂载全局接口方法,故这里只能使用微信原生方法
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
mask : true
|
||||
})
|
||||
wx.$api.mall.goodsSee(this.data.goodsId).then(res => {
|
||||
this.setData({
|
||||
goodsData : res.data,
|
||||
mallContent : res.data.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
|
||||
skus : res.data.skus,
|
||||
skuid : res.data.skus[0].sku_id,
|
||||
selectSkusValues: res.data.skus[0],
|
||||
specselect : res.data.skus[0].unit.split('|'),
|
||||
invite : res.data.invite
|
||||
})
|
||||
}).catch(err =>{}).finally(() => {
|
||||
wx.hideLoading()
|
||||
wx.request({
|
||||
url : 'https://api.xhtest.douhuofalv.com/api/mall/goods/' + this.data.goodsId,
|
||||
header : {
|
||||
"Accept" : "application/json",
|
||||
"channel" : "client",
|
||||
"Authorization" : wx.getStorageSync("token") || ""
|
||||
},
|
||||
success: res => {
|
||||
wx.hideLoading()
|
||||
let { statusCode, data } = res
|
||||
if(statusCode == 200){
|
||||
let dataOBJ = data.data
|
||||
this.setData({
|
||||
goodsData : dataOBJ,
|
||||
mallContent : dataOBJ.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
|
||||
skus : dataOBJ.skus,
|
||||
skuid : dataOBJ.skus[0].sku_id,
|
||||
selectSkusValues: dataOBJ.skus[0],
|
||||
specselect : dataOBJ.skus[0].unit.split('|'),
|
||||
invite : dataOBJ.invite
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: data.message,
|
||||
icon : 'none'
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
title: err.errMsg,
|
||||
icon : 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
// wx.$api.mall.goodsSee(this.data.goodsId).then(res => {
|
||||
// this.setData({
|
||||
// goodsData : res.data,
|
||||
// mallContent : res.data.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
|
||||
// skus : res.data.skus,
|
||||
// skuid : res.data.skus[0].sku_id,
|
||||
// selectSkusValues: res.data.skus[0],
|
||||
// specselect : res.data.skus[0].unit.split('|'),
|
||||
// invite : res.data.invite
|
||||
// })
|
||||
// }).catch(err =>{
|
||||
// console.log(err)
|
||||
// }).finally(() => {
|
||||
// wx.hideLoading()
|
||||
// })
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -185,11 +253,11 @@ Page({
|
||||
} = this.data.selectSkusValues;
|
||||
if (stock > 0) {
|
||||
this.setData({
|
||||
skuid: sku_id,
|
||||
goodsSize: false
|
||||
skuid : sku_id,
|
||||
goodsSize : false
|
||||
})
|
||||
wx.navigateTo({
|
||||
url: '/pages/mall/confirm/confirm?skuId=' + sku_id + '&qty=' + this.data.qtyNumber
|
||||
url: '/pages/mall/confirm/confirm?skuId=' + sku_id + '&qty=' + this.data.qtyNumber || 1
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
@@ -270,7 +338,7 @@ Page({
|
||||
onShareTimeline(){
|
||||
return{
|
||||
title : this.data.goodsData.name,
|
||||
query : '/pages/mall/details/details?id=' + this.data.goodsId + '&invite=' + this.data.invite,
|
||||
query : 'id=' + this.data.goodsId + '&invite=' + this.data.invite,
|
||||
imageUrl : this.data.goodsData.cover
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<text class="goods-size-title">数量</text>
|
||||
<view class="goods-number" wx:if="{{selectSkusValues.stock != 0}}">
|
||||
<view class="goods-number-btn" bindtap="goodsNumber" data-type="remove">-</view>
|
||||
<input class="goods-number-input" value="{{qtyNumber}}" type="number" bindinput="goodsNumberInput" disabled></input>
|
||||
<input class="goods-number-input" value="{{qtyNumber}}" type="number" bindinput="goodsNumberInput" bindblur="goodsNumberBlur"></input>
|
||||
<view class="goods-number-btn" bindtap="goodsNumber" data-type="plus">+</view>
|
||||
</view>
|
||||
<view class="goods-number" wx:else>
|
||||
@@ -93,6 +93,6 @@
|
||||
<view class="active">抱歉,商品库存不足了 ~</view>
|
||||
</view>
|
||||
<view class="goods-size-btn" wx:else>
|
||||
<view bindtap="buyTap">立即购买</view>
|
||||
<button bindtap="buyTap" size="default" disabled="{{selectSkusValues.stock == 0 || qtyNumber == 0}}">立即购买</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -404,9 +404,11 @@ button[disabled]{
|
||||
border-right: 2rpx solid #d7d7d7;
|
||||
}
|
||||
|
||||
.goods-size-btn view {
|
||||
.goods-size-btn button[size="default"] {
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
font-size: 28rpx;
|
||||
background: #da2b54;
|
||||
color: white;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<view class="nowrap goodsItem-text">{{item.description}}</view>
|
||||
<view class="goodsItem-tips">
|
||||
<view class="goodsItem-price">¥{{item.original_price}}</view>
|
||||
<view class="goodsItem-sales">月销 {{item.sales}}</view>
|
||||
<view class="goodsItem-sales">浏览 {{item.clicks}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -25,11 +25,15 @@ Page({
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
let sceneCode = options.scene || null
|
||||
if(sceneCode != null ){
|
||||
let inviteCode = decodeURIComponent(sceneCode)
|
||||
let invite = inviteCode.match(new RegExp("(^|&)" + 'invite' + "=([^&]*)(&|$)", "i"));
|
||||
getApp().globalData.invite = invite[2] || null
|
||||
if(options.invite){
|
||||
getApp().globalData.invite = options.invite || null
|
||||
}else{
|
||||
let sceneCode = options.scene || null
|
||||
if(sceneCode != null ){
|
||||
let inviteCode = decodeURIComponent(sceneCode)
|
||||
let invite = inviteCode.match(new RegExp("(^|&)" + 'invite' + "=([^&]*)(&|$)", "i"));
|
||||
getApp().globalData.invite = invite[2] || null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -170,6 +174,21 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 开通vip
|
||||
*/
|
||||
onVip(){
|
||||
if(wx.getStorageSync("token") != ''){
|
||||
wx.navigateTo({
|
||||
url: '/pages/idcard/idcard',
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: "/pages/login/index"
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
|
||||
@@ -45,6 +45,11 @@
|
||||
<image class="capsule-src" src="/static/imgs/capsule.png" mode="widthFix" bind:tap="onCapsule"></image>
|
||||
</view>
|
||||
|
||||
<!-- 开通vip -->
|
||||
<view class="capsule" wx:if="{{certification}}">
|
||||
<image class="capsule-src" src="/static/imgs/vip.png" mode="widthFix" bind:tap="onVip"></image>
|
||||
</view>
|
||||
|
||||
<!-- 推荐 -->
|
||||
<view class="suggest">
|
||||
<view class="suggestLeft">
|
||||
@@ -123,7 +128,7 @@
|
||||
<view class="nowrap goodsItem-text">{{item.description}}</view>
|
||||
<view class="goodsItem-tips">
|
||||
<view class="goodsItem-price">¥{{item.original_price}}</view>
|
||||
<view class="goodsItem-sales">游览 {{item.clicks}}</view>
|
||||
<view class="goodsItem-sales">浏览 {{item.clicks}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</navigator>
|
||||
|
||||
Reference in New Issue
Block a user