Skip to content

Commit

Permalink
增加合成优惠券功能
Browse files Browse the repository at this point in the history
  • Loading branch information
gooking committed Jan 9, 2021
1 parent dacb328 commit 5182d76
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 76 deletions.
1 change: 1 addition & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"pages/fx/members",
"pages/fx/commisionLog",
"pages/coupons/index",
"pages/coupons/merge",
"pages/invoice/list",
"pages/invoice/apply",
"pages/deposit/pay",
Expand Down
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
version: '9.14.1',
note: '增加商品浏览足迹', // 这个为版本描述,无需修改
version: '9.15.0',
note: '增加合成优惠券功能', // 这个为版本描述,无需修改
subDomain: 'tz', // 此处改成你自己的专属域名。什么是专属域名?请看教程 https://www.it120.cc/help/qr6l4m.html
sdkAppID: 1400450467, // 腾讯实时音视频应用编号,请看教程 https://www.it120.cc/help/nxoqsl.html
}
Binary file removed images/notice.png
Binary file not shown.
4 changes: 2 additions & 2 deletions miniprogram_npm/apifm-wxapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ module.exports =

/* eslint-disable */
// 小程序开发api接口工具包,https://github.com/gooking/wxapi
var API_BASE_URL = 'https://api.it120.cc';
// var API_BASE_URL = 'http://127.0.0.1:8081';
// var API_BASE_URL = 'https://api.it120.cc';
var API_BASE_URL = 'http://127.0.0.1:8081';
var subDomain = '-';

var request = function request(url, needSubDomain, method, data) {
Expand Down
99 changes: 99 additions & 0 deletions pages/coupons/merge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
const WXAPI = require('apifm-wxapi')
const AUTH = require('../../utils/auth')
Page({
data: {

},
onLoad: function (options) {
this.mergeCouponsRules();
},
onShow: function () {

},
async mergeCouponsRules() {
const res = await WXAPI.mergeCouponsRules()
if (res.code == 0) {
this.setData({
mergeCouponsRules: res.data
})
}
},
onPullDownRefresh() {
this.mergeCouponsRules()
wx.stopPullDownRefresh()
},
async merge(e) {
const idx = e.currentTarget.dataset.idx
const mergeCouponsRule = this.data.mergeCouponsRules[idx]
this.setData({loading: true})
let res = await WXAPI.myCoupons({
token: wx.getStorageSync('token'),
status: 0
})
if (res.code == 700) {
wx.showToast({
title: '您暂无可用的优惠券',
icon: 'none'
})
this.setData({loading: false})
return
}
if (res.code != 0) {
wx.showToast({
title: res.msg,
icon: 'none'
})
this.setData({loading: false})
return
}
const myCoupons = res.data.reverse()
const couponIds = [] // 用来合成的优惠券id
let ok = true
let msg = ''
mergeCouponsRule.rules.filter(rule => {
return rule.type == 0
}).forEach(rule => {
for (let i = 0; i < rule.number; i++) {
const couponIndex = myCoupons.findIndex(ele => { return ele.pid == rule.couponId})
if (couponIndex == -1) {
ok = false
msg = rule.couponName
return
}
const coupon = myCoupons[couponIndex]
couponIds.push(coupon.id)
myCoupons.splice(couponIndex, 1)
}
})
if (!ok) {
wx.showToast({
title: '缺少优惠券:' + msg,
icon: 'none'
})
this.setData({loading: false})
return
}
res = await WXAPI.mergeCoupons({
token: wx.getStorageSync('token'),
mergeId: mergeCouponsRule.id,
couponIds: couponIds.join()
})
if (res.code != 0) {
wx.showToast({
title: res.msg,
icon: 'none'
})
this.setData({loading: false})
return
}
wx.showToast({
title: '兑换成功'
})
this.setData({loading: false})
setTimeout(() => {
wx.navigateBack({
delta: 0,
})
}, 1000);
}
})
4 changes: 4 additions & 0 deletions pages/coupons/merge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"navigationBarTitleText": "优惠券合成",
"enablePullDownRefresh": true
}
15 changes: 15 additions & 0 deletions pages/coupons/merge.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<van-empty wx:if="{{ !mergeCouponsRules }}" description="暂无合成规则" />
<van-cell-group wx:for="{{mergeCouponsRules}}" wx:key="id" title="{{ item.name }}">
<van-cell
wx:for="{{item.rules}}"
wx:for-item="rule"
wx:key="id"
icon="{{ rule.type == 0 ? 'delete' : 'share-o' }}"
title="{{ rule.typeStr }}"
label="优惠券:{{ rule.couponName }}"
value="{{rule.number}} 张"
/>
<view class="block-btn">
<van-button type="primary" block data-idx="{{ index }}" loading="{{ loading }}" bind:click="merge">立即合成</van-button>
</view>
</van-cell-group>
1 change: 1 addition & 0 deletions pages/coupons/merge.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* pages/coupons/merge.wxss */
6 changes: 6 additions & 0 deletions pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,11 @@ Page({
wx.navigateTo({
url: '/pages/search/index'
})
},
goNotice(e) {
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/notice/show?id=' + id,
})
}
})
5 changes: 4 additions & 1 deletion pages/index/index.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"enablePullDownRefresh": true
"enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#e64340",
"navigationBarTextStyle": "white",
"backgroundColor": "#e64340"
}
31 changes: 15 additions & 16 deletions pages/index/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
</view>
</view>
</navigator>
<van-search value="{{ value }}" placeholder="请输入搜索关键词" readonly background="#e64340" shape="round" bindtap="goSearch" />
<view class="swiper-container">
<swiper class="swiper1" indicator-dots="true" indicator-active-color="#fff" autoplay circular>
<swiper-item wx:for="{{banners}}" wx:key="id">
<image mode="aspectFill" bindtap="tapBanner" data-url="{{item.linkUrl}}" src="{{item.picUrl}}" />
<image mode="aspectFill" bindtap="tapBanner" data-url="{{item.linkUrl}}" src="{{item.picUrl}}" />
</swiper-item>
</swiper>
<view class="search" bindtap="goSearch">
<input type="text" placeholder="输入搜索关键词" disabled></input>
<image src="/images/icon/search.svg"></image>
</view>
<view wx:if="{{goodsDynamic}}" class="goodsDynamic">
<swiper class="swiper2" autoplay circular vertical>
<navigator wx:for="{{goodsDynamic}}" wx:key="index" url="/pages/goods-details/index?id={{item.goodsId}}">
Expand All @@ -34,17 +31,19 @@
</view>
</view>
<view class="notice-box" wx:if="{{noticeList}}">
<view class="notice">
<image class="notice_icon" src="/images/notice.png"></image>
<swiper class="notice_swiper" vertical autoplay circular>
<navigator wx:for="{{noticeList.dataList}}" wx:key="id" url="/pages/notice/show?id={{item.id}}">
<swiper-item>
<view class="notice_itemr">{{item.title}}</view>
</swiper-item>
</navigator>
</swiper>
</view>
<view class="more"><navigator url="/pages/notice/index">更多 ></navigator></view>
<swiper class="notice_swiper" vertical autoplay circular interval="8000">
<swiper-item wx:for="{{noticeList.dataList}}" wx:key="id">
<van-notice-bar
wx:if="{{noticeList}}"
left-icon="volume-o"
mode="link"
text="{{ item.title }}"
background="#FFFFFF"
data-id="{{ item.id }}"
bind:click="goNotice"
/>
</swiper-item>
</swiper>
</view>
<view class="category-box">
<view class="category-list" wx:for="{{categories}}" wx:key="id">
Expand Down
58 changes: 6 additions & 52 deletions pages/index/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,12 @@
width: 40rpx;
height: 40rpx;
}

.search {
position: absolute;
top: 32rpx;
left: 25rpx;
width: 700rpx;
height: 66rpx;
display: block;
box-sizing: border-box;
}
.search input {
display: block;
box-sizing: border-box;
background: rgba(255, 255, 255, 0.8);
border: 1rpx solid #e3e3e3;
width: 700rpx;
height: 66rpx;
border-radius: 30rpx;
padding-left: 32rpx;
}
.search image {
width: 35rpx;
height: 35rpx;
position: absolute;
top: 16rpx;
right: 32rpx;
z-index: 99;
}
.goodsDynamic {
position: absolute;
top: 110rpx;
left: 25rpx;
bottom: 64rpx;
left: 16rpx;
width: 650rpx;
background: rgba(0, 0, 0, 0.6);
background: rgba(0, 0, 0, 0.4);
color: #fff;
padding: 8rpx 16rpx;
border-radius: 32rpx;
Expand Down Expand Up @@ -88,41 +60,21 @@
overflow: hidden;
}
.notice-box {
display: flex;
box-sizing: border-box;
width: 100vw;
height: 88rpx;
line-height: 88rpx;
justify-content: space-between;
align-items: center;
padding-right: 32rpx;
border-bottom: 1rpx solid #efeff4;
}
.notice{
display: flex;
justify-content: space-between;
align-items: center;
width: 600rpx;
}
.notice_icon {
margin-left:20rpx;
width:30rpx;
height:30rpx;
}
.notice_swiper{
height: 88rpx;
width: 600rpx;
width: 100%;
}
.notice_itemr {
padding-left: 16rpx;
font-size: 24rpx;
overflow: hidden;
color: #e64340;
}
.notice-box .more {
color: #666;
font-size: 24rpx;
}

.container {
background-color: #fff;
Expand Down Expand Up @@ -169,6 +121,8 @@
.swiper-container .swiper1 image {
width: 750rpx;
height: 375rpx;
/* margin: 8rpx 15rpx; */
/* border-radius: 16rpx; */
}
::-webkit-scrollbar {
width: 0;
Expand Down
3 changes: 2 additions & 1 deletion pages/my/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
<van-cell title="资金明细" is-link url="/pages/asset/index" />
<van-cell title="申请发票" is-link url="/pages/invoice/apply" />
<van-cell title="发票记录" is-link url="/pages/invoice/list" />
<van-cell title="领券中心" is-link url="/pages/coupons/index" />
<van-cell title="领取优惠券" is-link url="/pages/coupons/index" />
<van-cell title="合成优惠券" is-link url="/pages/coupons/merge" />
</van-cell-group>
<van-cell-group title="三级分销">
<van-cell wx:if="{{!apiUserInfoMap.base.isSeller}}" title="成为分销商" is-link url="/pages/fx/apply-status" />
Expand Down
2 changes: 1 addition & 1 deletion pages/search/index.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"navigationBarTitleText": "搜索一下"
"navigationBarTitleText": "搜一搜"
}
2 changes: 1 addition & 1 deletion project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.14.1",
"libVersion": "2.14.3",
"appid": "wxa46b09d413fbcaff",
"projectname": "%E5%A4%A9%E4%BD%BF%E7%AB%A5%E8%A3%85",
"scripts": {},
Expand Down

0 comments on commit 5182d76

Please sign in to comment.