first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
a1bdcf33-63b5-458c-ae49-68241f0a946b

View File

@@ -0,0 +1,373 @@
// mall/placeOrder/placeOrder.js
const app = getApp();
const regeneratorRuntime = app.loadAsync()
const model = app.loadModel("index")
const http = app.loadHttp()
Page({
/**
* 页面的初始数据
*/
data: {
system: app.globalData.system, //设备相关信息
pageTitle: "提交订单", //头部标题
isBack: true,//显示返回
mode: "1",//收货方式 1门店 2收货
remark: "",//订单备注
address: {
all: "请选择收货地址",
userName: "姓名",
telNumber: "手机号"
},//收货地址
store: {
name: "亲! 请选择门店地址",
address: "选择门店地址"
},//门店地址信息
temCart: {},//购物车勾选的商品信息
oldCart: null,//购物车勾选中的信息原始样本
coupon: {},//优惠券
all: "",//总价
userInfo: {//用户姓名手机号 包河区 新艺苑
name: "",
tel: ""
},
giftCard: {},//卡劵
isgiftCard: "",//拼接的卡劵信息方便操作
isPay: 2,//1卡支付 2微信支付
postage: {},//邮费配置
},
// 订单备注
remarkInput(e) {
this.setData({
remark: e.detail.value
})
},
// 选择支付方式
selectPay(e) {
let type = e.currentTarget.dataset.type
let url = e.currentTarget.dataset.url
if (type == 2) {
this.setData({
isgiftCard: "",
giftCard: {},
isPay: type
})
} else if (type == 1) {
wx.navigateTo({
url: url
})
}
this._calculation()
},
// 获取选择的门店
async getStore() {
let res = await model.storage.getSetting("storeChange")
if (!!res) {
model.storage.deleteStorage('storeChange')
console.log(res)
if (JSON.stringify(res.store) == '{}'){
this.setData({
store: {
name: "未选择地址",
address: "您未选择任何门店,请留意,客服电话!!!"
},
userInfo: {
name: res.name,
tel: res.tel
}
})
}else{
this.setData({
store: res.store,
userInfo: {
name: res.name,
tel: res.tel
}
})
}
}
},
// 获取默认收货人
async getConsignee() {
let res = await http.http.request2({ url: `${http.api.defaultUserAddress}`, method: "POST" })
let add = res.data.data
if (!!add.id) {
add.all = add.provinceName + add.cityName + add.countryName + add.detail
this.setData({
address: add
})
}
},
// 选择收货方式
wayDelivery(e) {
let mode = e.currentTarget.dataset.mode
this.setData({
mode: mode
})
},
// 选择收货地址
receivingAdd() {
if (this.data.mode == 1) {
wx.navigateTo({
url: "/mall/chooseStores/chooseStores"
})
return
}
wx.navigateTo({
url: "/user/addList/addList"
})
},
// 获取收货地址并且赋值到页面
async getAdd() {
let data = await model.storage.getSetting("address")
if (!!data) {
model.storage.deleteStorage('address')
data.all = data.provinceName + data.cityName + data.countyName + data.detailInfo
this.setData({
address: data || ""
})
// If the wechat address is chosen and the back end doesn't want to handle it,
// let me add the address interface and add it as the default address.
if (!data.id) {
let addData = {
userName: data.userName,
telNumber: data.telNumber,
provinceName: data.provinceName,
cityName: data.cityName,
countryName: data.countyName,
address: data.all,
detail: data.detailInfo,
is_default: 1
}
http.http.request2({ url: `${http.api.userAddress}`, method: "POST", data: addData })
}
}
},
// 获取优惠券
async getCoupon() {
let coupon = await model.storage.getSetting("coupon")
if (!!coupon) {
model.storage.deleteStorage('coupon')
this.setData({
coupon: coupon
})
}
this._calculation()
},
// 获取卡劵
async getGiftCard() {
let giftCard = await model.storage.getSetting("giftCard")
if (!!giftCard) {
model.storage.deleteStorage('giftCard')
this.setData({
giftCard: giftCard,
isgiftCard: giftCard.title + " " + giftCard.price + '折',
isPay: 1
})
}
this._calculation()
},
// 计算商品优惠完的总价格
// 总 - 优惠券 + 运费
_calculation() {
let temCart = this.data.temCart
let coupon = this.data.coupon.price || 0
let postage = this.data.postage
let all = temCart.total - coupon
if (all <= parseFloat(postage.satisfy_money)) {
all += parseFloat(postage.postage_money)
}
if (this.data.mode == 1){
all-=10
}
this.setData({
all: all.toFixed(2)
})
},
// 商城下单
async storeOrder(e) {
let formId = e.detail.formId
if (!this.data.userInfo.tel && this.data.mode == 1) {
model.msg.dataMsg({
type: "warning",
content: "请选择收货手机号"
})
return
}
if (!this.data.address.all && this.data.mode == 2) {
model.msg.dataMsg({
type: "warning",
content: "请选择收货地址"
})
return
}
let products = this.data.temCart.allCart
let oldCart = this.data.oldCart
let arr3 = []
products.map((v, i) => {
let data = {
store_product_id: v.store_product_id,
count: v.count,
attr: v.attr,
image: v.image
}
arr3[i] = data
})
let data = {
take_type: 1,
shop_id: 0,
username: "",
telnum: 0,
address_id: 0,
products: arr3,
remark: this.data.remark
}
if (this.data.mode == 1) {
data.take_type = 2
data.username = this.data.userInfo.name
data.telnum = this.data.userInfo.tel
if (this.data.store.id !== 'null' || this.data.store.id !== 'undefined'){
data.shop_id = this.data.store.id || 0
}
} else if (this.data.mode == 2) {
data.address_id = this.data.address.id
}
let res = await http.http.request2({ url: `${http.api.storeOrder}`, method: "POST", data: data })
// 下单成功时候就清除购物车
let rel = res.data.data
// 如果下单成功掉支付
if (rel.pass) {
model.shopCart.deleteCart(oldCart)
let payData = {
orderID: rel.store_order_id,
payType: this.data.isPay,
form_id: formId,
userCouponID: 0,
userCardID: 0
}
// 优惠券
if (!!this.data.coupon.id) {
payData.userCouponID = this.data.coupon.id
}
// 卡
if (this.data.isPay == 1) {
payData.userCardID = this.data.giftCard.id
}
// 吊起支付
let pay = await model.payment.pay(http.api.pre_order, payData)
if(pay == 3) return;
if (pay == 1) {
wx.redirectTo({
url: "/mall/paid/paid?name=支付成功"
})
return
}
setTimeout(() => {
wx.redirectTo({
url: "/mall/paid/paid?name=待支付"
})
}, 800)
}
},
// 获取当前邮费配置
async postage() {
let res = await http.http.request2({ url: `${http.api.postage}`, method: "POST", data: { type: 1 } })
if (res.data.status) {
this.setData({
postage: res.data.data
})
}
this._calculation()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getConsignee()
var that = this
app.setWatching('temCart', (n) => {
// 深拷贝,保留一份原始选中,方便删除
var _obj = JSON.stringify(n),
objClone = JSON.parse(_obj);
let temCart = n
let allCart = temCart.allCart
let attr = ""
allCart.map((v, i) => {
allCart[i].count = allCart[i].num
allCart[i].store_product_id = allCart[i].id
if (!(typeof v.attr == "string")) {
if (v.attr.length > 0) {
v.attr.map((v, i) => {
attr += v + ","
})
allCart[i].attr = attr.substr(0, attr.length - 1)
} else {
allCart[i].attr = ""
}
attr = ""
}
})
temCart.allCart = allCart
// temCart.total = (temCart.total).toFixed(2)
that.setData({
temCart: temCart,
oldCart: objClone
})
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.postage()
this.getAdd()
this.getCoupon()
this.getStore()
this.getGiftCard()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@@ -0,0 +1,6 @@
{
"usingComponents": {
"wux-cell-group": "../../extend/wux/dist/cell-group/index",
"wux-cell": "../../extend/wux/dist/cell/index"
}
}

View File

@@ -0,0 +1,100 @@
<!-- 头部 -->
<nav-bar isBack="{{isBack}}" pageTitle="{{pageTitle}}" system="{{system}}" />
<!-- mall/placeOrder/placeOrder.wxml -->
<view class="placeOrder">
<view class="expMode flex-con3">
<view class="mode_cen">
<view data-mode="1" bind:tap="wayDelivery" class="mode {{ mode == 1 ? 'mode_active' :'' }}">
门店自取
</view>
<!-- <view data-mode="2" bind:tap="wayDelivery" class="mode {{ mode == 2 ? 'mode_active' :'' }}">
快递寄送
</view> -->
</view>
</view>
<view class="pd20">
<view class="receiving mt30 flex-con3" bind:tap="receivingAdd">
<view class="dis-flex flex1">
<view class="flex1">
<view class="flex-con1 receiving_img clamp1">
<image class="{{ mode == 1 ? 'receiving_img2' : '' }}" src="{{ mode == 1 ? '/static/img/icon/add2.png' : '/static/img/icon/add1.png' }}" />
<span wx:if="{{ mode == 1 }}" class="flex1 ml20">
{{ store.name }} {{store.telnum ? "("+store.telnum +")" :""}}
</span>
<span wx:if="{{ mode == 2 }}" class="flex1 ml20">{{ address.all }}</span>
</view>
<view wx:if="{{ mode == 1 }}" class="mt30 receiving_p">
{{ store.address }}
</view>
<view wx:if="{{ mode == 2 }}" class="mt30 receiving_p">
{{ address.userName }} {{ address.telNumber }}
</view>
</view>
<view class="flex-con3 receiving-r">
<image src="/static/img/icon/right-r.png" />
</view>
</view>
</view>
<view class="shop_list mt20">
<view class="shop_list_row dis-flex" wx:for="{{ temCart.allCart }}" wx:key="{{ index }}">
<view class="shop_list_img">
<image src="{{item.image}}" />
</view>
<view class="flex1 ml20 dis-flex1">
<view class="flex1 flex-con2">
<view class="flex1 text1">{{item.name}}</view>
<view class="flex1 text-right text1">¥{{item.price}}</view>
</view>
<view class="flex1 flex-con2">
<view class="flex1 text2">
<span>
{{item.attr}}
</span>
</view>
<view class="flex1 text-right text1">×{{item.num}}</view>
</view>
</view>
</view>
</view>
<view class="mt20">
<wux-cell-group>
<wux-cell data-type="2" bind:tap="selectPay" thumb="/static/img/icon/wxlogo2.png" title="微信支付" rightUrl="{{isPay == 2 ? '/static/img/icon/wxPay2.png' : '/static/img/icon/wxPay1.png'}}"></wux-cell>
<wux-cell data-type="1" bind:tap="selectPay" data-url="/user/payment/card/card?type=1" right="text_right_cell2" thumb="{{!!giftCard.logo?giftCard.logo:'/static/img/icon/yhk.png'}}" title="{{isgiftCard != ''?isgiftCard:'会员卡支付'}}" rightUrl="{{isPay == 1 ? '/static/img/icon/wxPay2.png' : '/static/img/icon/wxPay1.png'}}"></wux-cell>
</wux-cell-group>
</view>
<view class="mon mt20">
<!-- <navigator url="/mall/couponCard/couponCard?total={{temCart.total}}" class="mon_cen pdtb20 dis-flex">
<view class="flex1 mon_p">优惠</view>
<view class="flex1 flex-con5 mon_span">
<image src="/static/img/icon/right-r.png" />
<span wx:if="{{ !!coupon && !!coupon.price }}" class="mr20">-¥{{coupon.price}}</span>
<span wx:else class="mr20">选择优惠券</span>
</view>
</navigator> -->
<view class="mon_cen pdtb20 dis-flex">
<view class="flex1 mon_p">商品总金额</view>
<view class="flex1 text-right mon_p">¥{{temCart.total}}</view>
</view>
<!-- <view class="mon_cen pdtb20 dis-flex">
<view class="flex1 mon_p">运费</view>
<view class="flex1 text-right mon_p">¥{{temCart.total>postage.satisfy_money?0:(mode==1?0:postage.postage_money)}}</view>
</view> -->
<view class="mt20 pt40 pb20 rem flex-con2">
<view class="dis-flex mon_p">备注</view>
<input class="flex1" type="text" bindinput="remarkInput" placeholder="如有问题请备注" />
</view>
</view>
</view>
</view>
<!-- 支付 -->
<view class="shop_pay">
<view class="flex-con5 flex1 pay_num">
合计:¥{{all<=0?0:all}}
</view>
<form report-submit bindsubmit="storeOrder">
<button class="pay_sub" form-type="submit">支付</button>
</form>
</view>
<!-- toasta提示 -->
<i-toast id="toast" />

View File

@@ -0,0 +1,183 @@
/* mall/placeOrder/placeOrder.wxss */
.placeOrder {
margin-bottom: 120rpx;
}
.expMode {
width: 750rpx;
height: 90rpx;
background-color: #1dbf53;
}
.mode_cen {
display: flex;
height: 60rpx;
line-height: 60rpx;
}
.mode {
flex: 1;
padding: 0 45rpx;
font-family: PingFang-SC-Bold;
font-size: 28rpx;
color: #beffd4;
}
.mode_active {
background-color: #fff;
border-radius: 30rpx;
color: #1dbf53;
text-align: center;
}
.receiving {
width: 710rpx;
height: 180rpx;
background-color: #fff;
border-radius: 10rpx;
padding: 0 29rpx;
}
.receiving_img {
font-family: PingFang-SC-Bold;
font-size: 34rpx;
font-weight: 700;
color: #333;
}
.receiving_img image {
width: 30rpx;
height: 36rpx;
vertical-align: middle;
}
.receiving_img2 {
width: 36rpx !important;
height: 34rpx !important;
}
.receiving_p {
font-family: PingFang-SC-Medium;
font-size: 28rpx;
color: #999;
}
.receiving-r image {
width: 14rpx;
height: 30rpx;
}
.shop_list {
padding: 40rpx 0;
background-color: #fff;
border-radius: 10rpx;
}
.shop_list_row {
height: 100rpx;
padding: 0 30rpx;
margin-bottom: 44rpx;
}
.shop_list_row:last-child {
margin-bottom: 0;
}
.shop_list_img image {
width: 100rpx;
height: 100rpx;
}
.text1 {
font-family: PingFang-SC-Medium;
font-size: 28rpx;
color: #333;
}
.text2 {
font-family: PingFang-SC-Medium;
font-size: 22rpx;
color: #999;
}
.mon {
padding: 20rpx 30rpx;
background-color: #fff;
}
.mon_p {
font-family: PingFang-SC-Medium;
font-size: 28rpx;
color: #333;
}
.mon_span {
font-family: PingFang-SC-Medium;
font-size: 28rpx;
color: #ff4838;
}
.mon_span image {
height: 28rpx;
width: 15rpx;
}
.rem {
border-top: 2rpx solid #ebebeb;
}
.rem input {
padding-left: 30rpx;
}
/* 支付 */
.shop_pay {
position: fixed;
height: 100rpx;
bottom: 0;
left: 0;
right: 0;
width: 100%;
display: flex;
background-color: #fff;
border-bottom: 2rpx solid #ebebeb;
z-index: 99999;
}
.pay_sub {
width: 260rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #1dbf53;
font-family: PingFang-SC-Medium;
font-size: 32rpx;
color: #fff;
border-radius: 0;
border: 0;
}
pay_sub::after{
width: 0;
height: 0;
border: 0;
}
.pay_num {
margin-right: 30rpx;
font-weight: 600;
font-family: PingFang-SC-Bold;
font-size: 30rpx;
color: #333;
}
/* 新增 */
.pla-se-card{
padding-top: 20rpx;
padding-bottom: 20rpx;
}
.pla-se-card-img{
height: 28rpx;
width: 15rpx;
}