商城红包
This commit is contained in:
parent
3e9c0348c5
commit
980724bb30
13
app/app.json
13
app/app.json
@ -1,15 +1,16 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/order/list",
|
||||
"pages/order/show",
|
||||
"pages/order/review",
|
||||
"pages/index/index",
|
||||
"pages/index/search",
|
||||
"pages/index/category",
|
||||
"pages/order/show",
|
||||
"pages/order/quasi",
|
||||
"pages/mine/coupon",
|
||||
"pages/shop/show",
|
||||
"pages/mine/mine",
|
||||
"pages/order/list",
|
||||
"pages/order/review",
|
||||
"pages/index/search",
|
||||
"pages/index/category",
|
||||
"pages/address/select",
|
||||
"pages/order/quasi",
|
||||
"pages/address/list",
|
||||
"pages/index/address",
|
||||
"pages/address/add",
|
||||
|
BIN
app/images/icon_hongbao2.png
Normal file
BIN
app/images/icon_hongbao2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
@ -7,7 +7,7 @@ var initCount = 60
|
||||
Page({
|
||||
data: {
|
||||
codeLabel: '获取验证码',
|
||||
phone: '13000000004',
|
||||
phone: '',
|
||||
},
|
||||
onLoad: function (options) {
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
|
139
app/pages/mine/coupon.js
Normal file
139
app/pages/mine/coupon.js
Normal file
@ -0,0 +1,139 @@
|
||||
// pages/mine/coupon.js
|
||||
import {
|
||||
getShareUserList
|
||||
} from '../../utils/apis'
|
||||
|
||||
import {
|
||||
getPrevPage
|
||||
} from '../../utils/util'
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
page: 0,
|
||||
hasMore: true,
|
||||
loading: false,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.id = options.id || 30
|
||||
this.callback = options.callback || 'callback'
|
||||
this.setData({
|
||||
selectedId: this.id
|
||||
})
|
||||
this.loadData()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom(e) {
|
||||
var {
|
||||
hasMore, loading
|
||||
} = this.data
|
||||
if (hasMore && !loading) {
|
||||
this.loadData()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
loadData() {
|
||||
var that = this
|
||||
var {
|
||||
loading, page
|
||||
} = this.data
|
||||
if (loading) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
loading: true
|
||||
})
|
||||
getShareUserList({
|
||||
page,
|
||||
success(data) {
|
||||
var {list} = that.data
|
||||
var {list: list2, has_more, page} = data
|
||||
list2 = list2.map(item => {
|
||||
item['deadline_time_format'] = item.deadline_time.split(' ')[0]
|
||||
return item
|
||||
})
|
||||
that.setData({
|
||||
loading: false,
|
||||
list: list ? list.concat(list2) : list2,
|
||||
hasMore: has_more,
|
||||
page: page + 1
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
onItemTap(e) {
|
||||
var {id} = e.currentTarget
|
||||
var {selectedId} = this.data
|
||||
if (id == selectedId) {
|
||||
return;
|
||||
}
|
||||
var callback = getPrevPage()[this.callback]
|
||||
callback && callback(id)
|
||||
wx.navigateBack()
|
||||
}
|
||||
})
|
3
app/pages/mine/coupon.json
Normal file
3
app/pages/mine/coupon.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "我的红包"
|
||||
}
|
28
app/pages/mine/coupon.wxml
Normal file
28
app/pages/mine/coupon.wxml
Normal file
@ -0,0 +1,28 @@
|
||||
<!--pages/mine/coupon.wxml-->
|
||||
<import src="/templates/load-more.wxml" />
|
||||
<view class="coupon-list">
|
||||
<view id="{{item.draw_id}}" bindtap="{{selectedId ? 'onItemTap' : ''}}" wx:for="{{list}}" wx:key="draw_id" class="coupon-item">
|
||||
<image wx:if="{{selectedId == item.draw_id}}" class="coupon-item__selected-img" src="/images/address_list_selected.png"></image>
|
||||
<view class="coupon-item__bd weui-flex">
|
||||
<view class="weui-flex__item">
|
||||
<view class="coupon-item__name">
|
||||
{{item.name}}
|
||||
</view>
|
||||
<view class="coupon-item__deadline">
|
||||
有效期至 {{item.deadline_time_format}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="coupon-item__money">
|
||||
¥
|
||||
<text class="coupon-item__money-num">{{item.money}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="coupon-item__ft">
|
||||
仅限{{item.phone}}使用
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<template is="load-more" data="{{hasMore: hasMore, loading: loading, noMoreLabel: '没有更多红包'}}"></template>
|
53
app/pages/mine/coupon.wxss
Normal file
53
app/pages/mine/coupon.wxss
Normal file
@ -0,0 +1,53 @@
|
||||
/* pages/mine/coupon.wxss */
|
||||
@import '/templates/load-more.wxss';
|
||||
|
||||
.coupon-list {
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.coupon-item {
|
||||
position: relative;
|
||||
margin-top: 10px;
|
||||
padding: 0 15px;
|
||||
background-color: #fff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.coupon-item__bd {
|
||||
padding: 15px 0 10px 0;
|
||||
}
|
||||
|
||||
.coupon-item__name {
|
||||
color: #ff5801;
|
||||
}
|
||||
|
||||
.coupon-item__deadline {
|
||||
color: #999;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.coupon-item__ft {
|
||||
padding: 5px 0;
|
||||
font-size: 0.8em;
|
||||
color: #999;
|
||||
border-top: 1rpx dashed #e8e8e8;
|
||||
}
|
||||
|
||||
.coupon-item__money {
|
||||
padding: 5px 10px;
|
||||
color: #ff5801;
|
||||
font-size: 1.2em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.coupon-item__money-num {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.coupon-item__selected-img {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 40px;
|
||||
height: 39px;
|
||||
}
|
@ -11,16 +11,23 @@
|
||||
{{loginInfo.phone}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cells">
|
||||
<navigator wx:if="{{loginInfo}}" url="/pages/address/list" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view wx:if="{{loginInfo}}" class="weui-cells">
|
||||
<navigator url="/pages/address/list" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view class="weui-cell__bd">收货地址</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
|
||||
</navigator>
|
||||
<navigator url="/pages/mine/coupon" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view class="weui-cell__bd">我的红包</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="weui-cells">
|
||||
<view data-phone="400-926-2108" bindtap="onPhoneTap" class="weui-cell weui-cell_access">
|
||||
<view class="weui-cell__bd">客服热线</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access">400-926-2108</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="button-sp-area">
|
||||
<button loading="{{loading}}" bindtap="onLogout" wx:if="{{loginInfo}}" class="weui-btn weui-btn_plain" >
|
||||
退出账号
|
||||
|
@ -1,6 +1,6 @@
|
||||
// pages/order/quasi.js
|
||||
import {
|
||||
getQuasiOrderInfo, updateOrderAddr,
|
||||
getQuasiOrderInfo, updateOrderAddr, updateOrderCoupon,
|
||||
addOrder, getPayment
|
||||
} from '../../utils/apis'
|
||||
|
||||
@ -13,7 +13,7 @@ Page({
|
||||
},
|
||||
onLoad: function (options) {
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
this.id = options.id || '2725'
|
||||
this.id = options.id || '2825'
|
||||
this.loadData()
|
||||
},
|
||||
onReady: function () {
|
||||
@ -42,6 +42,8 @@ Page({
|
||||
getQuasiOrderInfo({
|
||||
quasi_order_id: id,
|
||||
success(data) {
|
||||
data['cut_money_total'] = +data.cut_money + +data.coupon_money
|
||||
|
||||
that.setData({
|
||||
info: data,
|
||||
loading: false
|
||||
@ -69,6 +71,37 @@ Page({
|
||||
quasi_order_id: id,
|
||||
addr_id,
|
||||
success(data) {
|
||||
data['cut_money_total'] = +data.cut_money + +data.coupon_money
|
||||
that.setData({
|
||||
info: data,
|
||||
loading: false
|
||||
})
|
||||
wx.hideNavigationBarLoading()
|
||||
},
|
||||
error() {
|
||||
that.setData({
|
||||
loading: false
|
||||
})
|
||||
wx.hideNavigationBarLoading()
|
||||
}
|
||||
})
|
||||
},
|
||||
callbackCoupon(user_coupon_id) {
|
||||
var that = this
|
||||
var {id} = this
|
||||
var {loading} = this.data
|
||||
if (loading) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
loading: true
|
||||
})
|
||||
wx.showNavigationBarLoading()
|
||||
updateOrderCoupon({
|
||||
quasi_order_id: id,
|
||||
user_coupon_id,
|
||||
success(data) {
|
||||
data['cut_money_total'] = +data.cut_money + +data.coupon_money
|
||||
that.setData({
|
||||
info: data,
|
||||
loading: false
|
||||
|
@ -19,11 +19,11 @@
|
||||
<view class="weui-cell__bd">支付方式</view>
|
||||
<view class="">在线支付</view>
|
||||
</view>
|
||||
<navigator url="" wx:if="{{info.coupon_money > 0}}" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<navigator url="/pages/mine/coupon?id={{info.user_coupon_id}}&callback=callbackCoupon" wx:if="{{info.user_coupon_id}}" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view class="weui-cell__bd">红包</view>
|
||||
<view class="weui-cell__ft_in-access">¥{{info.coupon_money}}</view>
|
||||
</navigator>
|
||||
<view class="weui-cell weui-cell_access">
|
||||
<view wx:else class="weui-cell weui-cell_access">
|
||||
<view class="weui-cell__bd">红包</view>
|
||||
<view class="weui-cell__ft">暂无可用</view>
|
||||
</view>
|
||||
@ -42,7 +42,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="quasi-goods__list">
|
||||
<view class="quasi-goods__item">
|
||||
<view wx:if="{{info.packing_fee > 0}}" class="quasi-goods__item">
|
||||
<view class="quasi-goods__item-name">餐盒费</view>
|
||||
<view class="quasi-goods__item-num"></view>
|
||||
<view class="quasi-goods__item-price">¥{{info.packing_fee}}</view>
|
||||
@ -53,7 +53,7 @@
|
||||
<view class="quasi-goods__item-price">¥{{info.delivery_fee}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="quasi-goods__list">
|
||||
<view wx:if="{{info.cut_money > 0}}" class="quasi-goods__list">
|
||||
<view class="quasi-goods__item">
|
||||
<view class="quasi-goods__item-name quasi-goods__item-name_grey">
|
||||
<image class="quasi-goods__item-name-icon" src="/images/icon_jian.png"></image>商城优惠
|
||||
@ -65,7 +65,7 @@
|
||||
<view class="quasi-goods__list">
|
||||
<view class="quasi-goods__item">
|
||||
<view class="quasi-goods__item-name quasi-goods__item-name_grey">
|
||||
总计¥{{info.order_price}} 优惠¥{{info.cut_money}}
|
||||
总计¥{{info.order_price}} 优惠¥{{info.cut_money_total}}
|
||||
</view>
|
||||
<view class="quasi-goods__item-num"></view>
|
||||
<view class="quasi-goods__item-price primary-color">
|
||||
@ -77,7 +77,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="quasi-actions">
|
||||
<view class="quasi-actions__cut">已优惠¥{{info.cut_money}}</view>
|
||||
<view class="quasi-actions__cut">已优惠¥{{info.cut_money_total}}</view>
|
||||
<view class="quasi-actions__pay">
|
||||
待支付
|
||||
<text class="primary-color">¥{{info.pay_price}}</text>
|
||||
|
@ -49,9 +49,9 @@
|
||||
}
|
||||
|
||||
.quasi-goods__item-name-icon {
|
||||
margin: -2px 5px 0 0;
|
||||
height: 21px;
|
||||
width: 21px;
|
||||
margin: -4px 5px 0 0;
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ Page({
|
||||
},
|
||||
onLoad: function (options) {
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
this.id = options.id || 1468
|
||||
this.id = options.id || 1488
|
||||
this.loadData()
|
||||
},
|
||||
onReady: function () {
|
||||
@ -80,6 +80,7 @@ Page({
|
||||
order_id,
|
||||
success(data) {
|
||||
data['add_time_format'] = datetimeFormat(data.add_time)
|
||||
data['cut_money_total'] = +data.cut_money + +data.coupon_money
|
||||
data['flow'] = data.flow.map(item => {
|
||||
item['time_format'] = datetimeFormat(item.time)
|
||||
return item
|
||||
@ -107,13 +108,13 @@ Page({
|
||||
|
||||
onPhoneTap(e) {
|
||||
var that = this
|
||||
var {info: {seller_phone, localphone, delivery_phone}} = this.data
|
||||
var {info: {seller_phone, localphone, runner_phone}} = this.data
|
||||
var phones = [
|
||||
`商家电话: ${seller_phone}`,
|
||||
`客服电话: ${localphone}`
|
||||
]
|
||||
if(delivery_phone) {
|
||||
phones.push(`跑腿电话: ${delivery_phone}`)
|
||||
if (runner_phone) {
|
||||
phones.push(`跑腿电话: ${runner_phone}`)
|
||||
}
|
||||
wx.showActionSheet({
|
||||
itemList: phones,
|
||||
@ -124,7 +125,7 @@ Page({
|
||||
} else if (tapIndex == 1) {
|
||||
makePhoneCall(localphone)
|
||||
} else if(tapIndex == 2) {
|
||||
makePhoneCall(delivery_phone)
|
||||
makePhoneCall(runner_phone)
|
||||
}
|
||||
},
|
||||
fail: function (res) {
|
||||
|
@ -49,7 +49,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="quasi-goods__list">
|
||||
<view class="quasi-goods__item">
|
||||
<view wx:if="{{info.packing_fee > 0}}" class="quasi-goods__item">
|
||||
<view class="quasi-goods__item-name">餐盒费</view>
|
||||
<view class="quasi-goods__item-num"></view>
|
||||
<view class="quasi-goods__item-price">¥{{info.packing_fee}}</view>
|
||||
@ -60,19 +60,26 @@
|
||||
<view class="quasi-goods__item-price">¥{{info.delivery_fee}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="quasi-goods__list">
|
||||
<view class="quasi-goods__item">
|
||||
<view wx:if="{{info.cut_money > 0 || info.user_coupon_id}}" class="quasi-goods__list">
|
||||
<view wx:if="{{info.cut_money > 0}}" class="quasi-goods__item">
|
||||
<view class="quasi-goods__item-name quasi-goods__item-name_grey">
|
||||
<image class="quasi-goods__item-name-icon" src="/images/icon_jian.png"></image>商城优惠
|
||||
</view>
|
||||
<view class="quasi-goods__item-num"></view>
|
||||
<view class="quasi-goods__item-price">-¥{{info.cut_money}}</view>
|
||||
</view>
|
||||
<view wx:if="{{info.user_coupon_id}}" class="quasi-goods__item">
|
||||
<view class="quasi-goods__item-name quasi-goods__item-name_grey">
|
||||
<image class="quasi-goods__item-name-icon" src="/images/icon_hongbao.png"></image>红包
|
||||
</view>
|
||||
<view class="quasi-goods__item-num"></view>
|
||||
<view class="quasi-goods__item-price">-¥{{info.coupon_money}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="quasi-goods__list">
|
||||
<view class="quasi-goods__item">
|
||||
<view class="quasi-goods__item-name quasi-goods__item-name_grey">
|
||||
总计¥{{info.order_price}} 优惠¥{{info.cut_money}}
|
||||
总计¥{{info.order_price}} 优惠¥{{info.cut_money_total}}
|
||||
</view>
|
||||
<view class="quasi-goods__item-num"></view>
|
||||
<view class="quasi-goods__item-price primary-color">
|
||||
|
@ -371,6 +371,28 @@ export function updateOrderAddr(options) {
|
||||
|
||||
})
|
||||
}
|
||||
// 更新准订单红包
|
||||
export function updateOrderCoupon(options) {
|
||||
var {
|
||||
quasi_order_id, user_coupon_id,
|
||||
success, error
|
||||
} = options
|
||||
getApp().getLoginInfo(loginInfo => {
|
||||
if (!loginInfo.user_info) {
|
||||
return alert('用户未登录')
|
||||
}
|
||||
var {user_id, user_token} = loginInfo.user_info
|
||||
fetch({
|
||||
url: 'index.php?m=Mall&c=Order&a=updateOrderCoupon',
|
||||
data: {
|
||||
user_id, user_token,
|
||||
quasi_order_id, user_coupon_id
|
||||
},
|
||||
success, error
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// 添加订单
|
||||
export function addOrder(options) {
|
||||
@ -576,3 +598,26 @@ export function search(options) {
|
||||
}
|
||||
|
||||
|
||||
// 获取用户红包列表
|
||||
export function getShareUserList(options) {
|
||||
var {
|
||||
page,
|
||||
success, error
|
||||
} = options
|
||||
page = page || 0
|
||||
getApp().getLoginInfo(loginInfo => {
|
||||
if (!loginInfo.user_info) {
|
||||
return alert('用户未登录')
|
||||
}
|
||||
var {user_id, user_token} = loginInfo.user_info
|
||||
fetch({
|
||||
url: 'index.php?m=Mall&c=Coupon&a=getShareUserList',
|
||||
data: {
|
||||
user_id, user_token,
|
||||
page
|
||||
},
|
||||
success, error
|
||||
})
|
||||
|
||||
})
|
||||
}
|
@ -339,4 +339,13 @@ export function requestPayment(options) {
|
||||
}
|
||||
}
|
||||
}, data))
|
||||
}
|
||||
|
||||
// 分享
|
||||
export function share(options) {
|
||||
if (!wx.showShareMenu) {
|
||||
return alert('当前微信版本过低, 无法使用该功能, 请升级到最新微信版本后重试.')
|
||||
}
|
||||
|
||||
wx.showShareMenu(options)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user