This commit is contained in:
zhangmanman
2021-06-30 09:06:58 +08:00
parent b5c5316f8b
commit 34590d9f72
9 changed files with 900 additions and 15 deletions

View File

@@ -53,7 +53,10 @@ const unicom = (mobile, channel, code) => req({url: "unicom/get", method: "POST"
const merchant_card = (coupon_id) => req({url: "coupons/merchant_card", method: "GET", data:{coupon_id : coupon_id}})
// 获取商家券信息
const washcarBuy = () => req({url: "washcar/create"})
const washcarBuy = (welfare_id, right_id, qty, address_id) => req({url: "washcar/create", data:{welfare_id : welfare_id, right_id : right_id, qty : qty, address_id : address_id || ''}})
// 收银台提交
const washcarCreate = (welfare_id, right_id, qty, address_id, is_deliver) => req({url: "washcar/create", method: "POST", data:{welfare_id : welfare_id, right_id : right_id, qty : qty, address_id : address_id || '', is_deliver : is_deliver}})
export default({
index,
@@ -73,5 +76,6 @@ export default({
send,
unicom,
merchant_card,
washcarBuy
washcarBuy,
washcarCreate
})

View File

@@ -8,15 +8,42 @@ Page({
* 页面的初始数据
*/
data: {
rightId : '', //权益id
welfareId : '', //活动id
address : '', //默认地址
allAddress : '', //收货地址列表
detail : '', //权益详情
amount : '', //总金额
moreAmount : '', //产品金额
platIndex : 0, //选择提交方式下标
isdeliver : -1,
platformCp : [], //选择提交数组
num : 1, //购买的数量
content : '', //内容介绍
notification: '', //重要提示
remark : '', //使用须知
score : '', //应付总积分
freight : '', //运费
noticeShow : false, //须知显示状态
addressShow : false, //收货地址显示
payWayIndex : 0,
payWay :[
{value: 0, name: "微信支付"}
// {value: 1, name: "沃钱包支付"}
]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
console.log(options)
// this.couponInfo()
this.setData({
rightId : options.right_id,
welfareId: options.welfare_id
})
// 获取卡券列表
this.couponInfo()
},
/**
@@ -30,8 +57,243 @@ Page({
* 卡券列表
*/
couponInfo() {
wx.$api.user.washcarBuy().then(res=>{
console.log(res)
wx.$api.user.washcarBuy(this.data.welfareId, this.data.rightId, this.data.num, this.data.address.id).then(res=>{
let obj = res.data.detail.express
let defGet = res.data.detail.def_get
let arr = new Array
arr = Object.keys(obj).map(val=>{
return { ...obj[val], ...{key: val} }
})
if(this.data.isdeliver == -1){
if(res.data.detail.type == 'physical') {
this.setData({
isdeliver : res.data.detail.def_get
})
}
if(res.data.detail.type == 'virtual') this.setData({isdeliver : 1})
}
this.setData({
address : res.data.address,
allAddress : res.data.all_address,
detail : res.data.detail,
num : res.data.qty,
freight : res.data.freight,
platformCp : arr,
amount : res.data.total,
moreAmount : res.data.amount,
score : res.data.score,
remark : res.data.detail.remark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
content : res.data.detail.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"')
})
}).catch(err=>{
if(!err.login){
wx.showModal({
title : '用户登录已过期',
content : '请重新登录',
showCancel : false,
success : res => {
if (res.confirm) {
wx.redirectTo({
url: '/pages/login/login'
})
}
}
})
}
})
},
/**
* 须知展开收起状态
*/
noticeTap() {
this.setData({
noticeShow : !this.data.noticeShow
})
},
/**
* 收货地址弹出
*/
addressTap() {
this.setData({
addressShow : !this.data.addressShow
})
},
/**
* 选择收货地址
*/
selectAddress(e){
let new_addressId = e.currentTarget.dataset.id,
addressId = this.data.address.id
if (new_addressId != addressId) {
this.setData({
address : e.currentTarget.dataset.index,
addressShow : false
})
}else{
this.setData({
addressShow : false
})
}
// 获取卡券列表
this.couponInfo()
},
/**
* 支付选择
*/
payBind(e) {
this.setData({
payWayIndex: e.detail.value
})
},
/**
* 商品数量加减
*/
goodsNumber(e){
let num = this.data.num
if (e.currentTarget.dataset.type == 'plus'){
num ++;
}else{
if (num > 1){
num --;
}else{
wx.showToast({
title : '商品数量不能小于1',
icon : 'none'
})
}
}
this.setData({
num : num
})
// 获取详情
this.couponInfo()
},
/**
* 选择提交方式
*/
platBind(e) {
this.setData({
platIndex : e.detail.value,
isdeliver : this.data.platformCp[e.detail.value].value
})
// 获取详情
this.couponInfo()
},
/**
* 支付提交
*/
submitOrder() {
if(this.data.isdeliver.length == 0) {
this.setData({
isdeliver: this.data.detail.def_get
})
}
let right_id = this.data.rightId,
welfare_id = this.data.welfareId,
address_id = this.data.address.id,
is_deliver = this.data.isdeliver,
qty = this.data.num
wx.$api.user.washcarCreate(welfare_id, right_id, qty, address_id, is_deliver).then(res=>{
let dataUrl = '', //定义接口来源名称
type = res.data.type //订单来源
// welfare为福利活动购买
if(type == 'welfare') dataUrl = wx.$api.index.fridayInfo(welfare_id, address_id, is_deliver)
// right为权益购买
if(type == 'right') dataUrl = wx.$api.index.rightStore(right_id, address_id, is_deliver, qty)
// 第一步接口调取
dataUrl.then(dataRes=>{
let payUrl = '', //定义接口来源名称
Newtype = dataRes.data.type //订单来源
// welfare为福利活动购买
if(Newtype == 'welfare') payUrl = wx.$api.index.fridayPay(dataRes.data.trade_no)
// right为权益购买
if(Newtype == 'right') payUrl = wx.$api.index.wechat(dataRes.data.trade_no)
// 第一步接口调取
payUrl.then(payEes=>{
let payInfo = JSON.parse(payEes.data)
wx.requestPayment({
timeStamp: payInfo.timeStamp,
nonceStr : payInfo.nonceStr,
package : payInfo.package,
paySign : payInfo.paySign,
signType : payInfo.signType,
success : res=>{
if(res.errMsg == "requestPayment:ok"){
wx.showToast({
title: '支付成功',
icon : 'success'
})
if(Newtype == 'welfare'){
setTimeout(()=>{
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=welfareGoods'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=welfare'
})
}
},3000)
}
if(Newtype == 'right'){
setTimeout(()=>{
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=rightsCoupons'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=rights'
})
}
},3000)
}
}
},
fail : res=>{
if(Newtype == 'welfare'){
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=welfareGoods&stateType=unpay'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=welfare&stateType=unpay'
})
}
}
if(Newtype == 'right'){
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=rightsCoupons&stateType=unpay'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=rights&stateType=unpay'
})
}
}
}
})
})
})
})
}
})

View File

@@ -1,2 +1,172 @@
<!--pages/car/index.wxml-->
<text>pages/car/index.wxml</text>
<!-- 下单状态 -->
<view class="state">
<view class="state-title">
等待买家付款
<text>请您尽快下单购买</text>
</view>
<image class="state-img" src="/static/img/car_state.png"></image>
</view>
<!-- 默认地址 -->
<view class="content">
<view class="site">
<view class="siteCont" wx:if="{{address != ''}}" bindtap="addressTap">
<image class="siteCont-site" src="/static/img/car_site.png"></image>
<view class="siteCont-right">
<view class="site-text">
{{address.name}} <text>{{address.mobile}}</text>
</view>
<view class="site-all">{{address.all_address}}</view>
</view>
<image class="state-arrow" src="/static/icon/arrow_left.png"></image>
</view>
<navigator hover-class="none" url="/pages/address/address?type=selectAddress" class="siteTips" wx:else>
<view class="siteTips-tips"><image src="/static/img/carSite_add.png"></image> 暂无收货地址</view>
</navigator>
</view>
<view class="goods">
<view class="goods-content">
<view class="goods-cover">
<image class="goods-image" src="{{detail.cover}}"></image>
<view class="goods-type {{detail.type == 'virtual' ? 'active' : ''}}">
<text>{{detail.type == 'virtual' ? '券' : '实'}}</text>
</view>
</view>
<view class="goods-cont">
<view class="nowrap goods-title">
{{detail.title}}
</view>
<view class="goods-qty">
数量x{{num}}
</view>
</view>
</view>
</view>
<!-- 规格 -->
<view class="label">
<view class="labelList">
<view class="labelList-label">
{{detail.attribute.form_price}}
</view>
<view class="labelList-price">
¥{{moreAmount}}
</view>
</view>
<view class="labelList">
<view class="labelList-label">{{detail.attribute.form_type}}</view>
<view class="labelList-price rightsLabel-red">¥{{score}}</view>
</view>
<view class="labelList">
<view class="labelList-label">{{detail.attribute.form_pay}}</view>
<view class="labelList-price rightsLabel-red">¥{{amount}}</view>
</view>
<view class="labelList">
<view class="labelList-label">
运费
</view>
<view class="labelList-price">
¥{{freight}}
</view>
</view>
</view>
<!-- 购买数量 -->
<view class="label">
<view class="labelList">
<view class="labelList-label">
购买数量
</view>
<view class="rightsAdd">
<view class="rightsAdd-btn" bindtap="goodsNumber" data-type="remove">-</view>
<text class="rightsAdd-input">{{num}}</text>
<view class="rightsAdd-btn" bindtap="goodsNumber" data-type="plus">+</view>
</view>
</view>
</view>
<!-- 提交方式 -->
<view class="label">
<view class="labelList">
<view class="labelList-label">请选择提交方式</view>
<view class="rightsLabel-range">
<picker range="{{platformCp}}" range-key="name" bindchange="platBind">
<view class="tabs-text">
{{platformCp[platIndex].name}}
</view>
</picker>
<image class="rightsLabel-row" src="/static/icon/rightsArrow.png"></image>
</view>
</view>
</view>
<!-- 支付方式 -->
<view class="label">
<view class="labelList">
<view class="labelList-label">请选择支付方式</view>
<view class="rightsLabel-range">
<picker range="{{payWay}}" range-key="name" bindchange="payBind">
<view class="tabs-text">
{{payWay[payWayIndex].name}}
</view>
</picker>
<image class="rightsLabel-row" src="/static/icon/rightsArrow.png"></image>
</view>
</view>
<view class="labelList">
<view class="labelList-label">支付方式</view>
<view class="labelList-price">{{payWay[payWayIndex].name}}</view>
</view>
</view>
<!-- 购买须知 -->
<view class="notice">
<view class="noticeTitle" bindtap="noticeTap">
<view class="noticeTitle-flex">
<image class="noticeTitle-img" src="/static/icon/notice_icon.png"></image>
购买前请仔细阅读使用须知、内容介绍
</view>
<image class="noticeTitle-row {{noticeShow ? 'active' : ''}}" src="/static/icon/rightsArrow.png"></image>
</view>
<view class="noticeText {{noticeShow ? 'active' : ''}}">
<view class="noticeText-top">购买须知</view>
<view class="noticeText-cont">
<rich-text nodes="{{remark}}"></rich-text>
</view>
<view class="noticeText-top">内容介绍</view>
<view class="noticeText-cont">
<rich-text nodes="{{content}}"></rich-text>
</view>
</view>
</view>
</view>
<!-- 立即购买 -->
<view class="buy">
<view class="buy-price">实际付款<text>¥{{amount}}</text></view>
<view class="buy-btn" bindtap="submitOrder">立即购买</view>
</view>
<!-- 选择收货地址 -->
<view class="addressBack {{addressShow ? 'active':''}}"></view>
<view class="addressCont {{addressShow ? 'active':''}}">
<view class="addressCont-title uni-border-bottom">
<view class="addressCont-left">请选择收货地址</view>
<view class="addressCont-right" bindtap="addSelect">新增收货地址</view>
</view>
<scroll-view class="header-classify" scroll-y="true">
<view class="addressCont-list uni-border-bottom" wx:for="{{allAddress}}" wx:key="allAddress"
bindtap="selectAddress" data-id="{{item.id}}" data-index="{{item}}">
<view class="addressCont-top">
<view class="addressCont-name">{{item.name}}</view>
<view class="addressCont-tel">{{item.mobile}}</view>
</view>
<view class="addressCont-text">
{{item.all_address}}
</view>
<view class="address-tool-icon">选择地址</view>
</view>
</scroll-view>
</view>

View File

@@ -1 +1,448 @@
/* pages/car/index.wxss */
/* 下单状态 */
.state {
background: #2e71e3;
padding: 30rpx 100rpx 60rpx;
width: 100%;
box-sizing: border-box;
color: #fff;
font-size: 26rpx;
display: flex;
}
.state-title {
flex: 1;
font-size: 32rpx;
}
.state-title text {
opacity:.8;
display: block;
font-size: 28rpx;
margin-top: 10rpx;
}
.state-img {
width: 70rpx;
height: 70rpx;
margin-top: 10rpx;
}
/* 默认地址 */
.content {
padding: 0 30rpx;
box-sizing: border-box;
width: 100%;
border-bottom: solid transparent 120rpx;
}
.site {
background-color: #fff;
margin-top: -30rpx;
border-radius: 10rpx;
padding: 30rpx;
box-sizing: border-box;
box-shadow: 0 0 10rpx rgba(0, 0, 0, .1);
}
.siteTips {
text-align: center;
}
.siteTips-tips {
color: #2e71e3;
border: #2e71e3 2rpx solid;
display: inline-block;
font-size: 28rpx;
line-height: 70rpx;
padding: 0 20rpx;
text-align: center;
margin: 0 auto;
}
.siteTips-tips image {
width: 32rpx;
height: 32rpx;
vertical-align: -5rpx;
padding-right: 10rpx;
}
.siteCont {
display: flex;
position: relative;
}
.siteCont-right {
width: calc(100% - 70rpx);
margin-left: 30rpx;
}
.state-arrow {
position: absolute;
right: 0;
top: 24rpx;
width: 34rpx;
height: 34rpx;
}
.siteCont-site {
width: 40rpx;
height: 40rpx;
margin-top: 24rpx;
}
.site-text {
margin-bottom: 10rpx;
}
.site-text text {
padding-left: 10rpx;
color: #999;
font-size: 28rpx;
}
.site-all {
font-size: 26rpx;
}
.goods {
width: 100%;
background-color: #fff;
border-radius: 10rpx;
padding: 30rpx;
box-sizing: border-box;
box-shadow: 0 0 10rpx rgba(0, 0, 0, .1);
margin: 30rpx 0;
}
.goods-content {
position: relative;
}
.goods-cont {
position: absolute;
left: 0;
top: 0;
width: 100%;
padding-left: 150rpx;
box-sizing: border-box;
}
.goods-title {
margin: 10rpx 0 20rpx;
font-weight: 600;
font-size: 30rpx;
}
.goods-qty {
color: #999;
font-size: 28rpx;
}
.goods-cover {
position: relative;
width: 130rpx;
height: 130rpx;
}
.goods-image {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.goods-type {
position: absolute;
z-index: 2;
left: 15rpx;
top: 15rpx;
font-size: 24rpx;
background-color: #5d69fb;
color: #fff;
border-radius: 50rpx;
height: 36rpx;
line-height: 34rpx;
padding: 0 6rpx;
}
.goods-type.active {
background-color: #fb5d64;
}
.goods-type text {
transform: scale(.9);
display: inline-block;
}
/* 规格 */
.label {
background-color: #fff;
border-radius: 10rpx;
padding: 10rpx 30rpx;
width: 100%;
box-sizing: border-box;
box-shadow: 0 0 10rpx rgba(0, 0, 0, .1);
margin-bottom: 30rpx;
position: relative;
}
.labelList {
display: flex;
line-height: 80rpx;
font-size: 28rpx;
}
.labelList-label {
flex: 1;
}
.rightsLabel-range {
display: flex;
color: #000;
}
.rightsLabel-row {
width: 38rpx;
height: 38rpx;
margin: 20rpx 0 0 6rpx;
}
.rightsAdd {
display: flex;
padding-top: 14rpx;
}
.rightsAdd-btn {
background: #eaeaea;
color: #535353;
border-radius: 50%;
text-align: center;
width: 50rpx;
height: 50rpx;
line-height: 45rpx;
font-size: 40rpx;
font-weight: 600;
}
.rightsAdd-input {
width: 60rpx;
text-align: center;
font-size: 28rpx;
line-height: 50rpx;
}
/* 购买 */
.buy {
position: fixed;
width: 100%;
left: 0;
bottom: 0;
height: 100rpx;
line-height: 100rpx;
background-color: #fff;
}
.buy-price {
background-color: #f1cb4c;
color: #8d5226;
width: calc(100% - 240rpx);
position: absolute;
left: 0;
top: 0;
height: 100%;
padding-left: 50rpx;
box-sizing: border-box;
font-weight: 600;
font-size: 32rpx;
}
.buy-price text {
font-size: 42rpx;
}
.buy .buy-btn {
background-color: #2e71e3;
color: #fff;
position: absolute;
right: 0;
top: 0;
width: 240rpx;
text-align: center;
height: 100%;
}
/* 购买须知 */
.notice {
background: white;
margin: 30rpx 0;
border-radius: 10rpx;
padding: 10rpx 0;
box-sizing: border-box;
box-shadow: 0 0 30rpx rgba(0,0,0,.15);
padding: 20rpx;
}
.noticeTitle {
display: flex;
}
.noticeTitle-flex {
flex: 1;
display: flex;
font-size: 28rpx;
line-height: 46rpx;
}
.noticeTitle-img {
width: 46rpx;
height: 46rpx;
margin-right: 20rpx;
}
.noticeText {
font-size: 26rpx;
height: 0;
overflow: hidden;
}
.noticeText.active {
height: auto;
}
.noticeText-top {
margin: 30rpx 0 10rpx;
font-weight: 600;
}
.noticeText-cont {
line-height: 60rpx;
}
.noticeTitle-row {
width: 46rpx;
height: 46rpx;
}
.noticeTitle-row.active {
transform: rotate(90deg);
}
/* 选择收货地址 */
.addressBack {
position: fixed;
left: 0;
bottom: 0;
background: rgba(0, 0, 0, .4);
z-index: 10;
width: 100%;
height: 100%;
display: none;
}
.addressBack.active {
display: block;
}
.addressCont {
position: fixed;
left: 0;
bottom: -1000%;
transition: .2s;
background: #fff;
z-index: 11;
width: 100%;
}
.addressCont.active {
bottom: 0;
}
.addressCont-title {
height: 90rpx;
line-height: 90rpx;
display: flex;
padding: 0 30rpx;
box-sizing: border-box;
font-size: 28rpx;
font-weight: 600;
}
.addressCont-left {
flex: 1;
}
.addressCont-right {
color: #309ded;
}
.header-classify {
white-space: nowrap;
box-sizing: border-box;
height: 600rpx;
}
.addressCont-list {
padding: 30rpx 20rpx;
box-sizing: border-box;
font-size: 30rpx;
overflow: hidden;
position: relative;
}
.addressCont-top {
display: flex;
margin-bottom: 10rpx;
}
.addressCont-name {
font-weight: 600;
}
.addressCont-text {
color: #666;
width: calc(100% - 160rpx);
}
.addressCont-list:last-child {
border: none;
}
.address-tool {
display: flex;
float: right;
}
.address-tool-btn {
font-size: 24rpx;
margin-top: 20rpx;
border: 2rpx solid #666;
color: #666;
border-radius: 6rpx;
text-align: center;
height: 50rpx;
line-height: 50rpx;
padding: 0 20rpx;
margin-right: 20rpx;
display: flex;
}
.address-tool-btn-del {
color: #dfae2e;
border-color: #dfae2e;
}
.address-tool-icon {
width: 120rpx;
height: 54rpx;
line-height: 54rpx;
border-radius: 4rpx;
text-align: center;
color: #fff;
position: absolute;
top: 45rpx;
right: 10rpx;
background: #dfae2e;
transform: scale(.9, .9);
font-size: 24rpx;
}

View File

@@ -26,6 +26,8 @@ Page({
orderType: options.orderType,
stateType: options.stateType
})
console.log(options.orderType)
},
onShow() {

View File

@@ -118,11 +118,11 @@ Page({
content : '请重新登录',
showCancel : false,
success : res => {
if (res.confirm) {
wx.redirectTo({
url: '/pages/login/login'
})
}
if (res.confirm) {
wx.redirectTo({
url: '/pages/login/login'
})
}
}
})
}

BIN
static/img/carSite_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
static/img/car_site.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
static/img/car_state.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB