提交 5182d76a 编写于 作者: api工厂's avatar api工厂

增加合成优惠券功能

上级 dacb3289
......@@ -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",
......
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
}
\ No newline at end of file
......@@ -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) {
......
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);
}
})
\ No newline at end of file
{
"navigationBarTitleText": "优惠券合成",
"enablePullDownRefresh": true
}
\ No newline at end of file
<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>
\ No newline at end of file
/* pages/coupons/merge.wxss */
\ No newline at end of file
......@@ -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,
})
}
})
\ No newline at end of file
{
"enablePullDownRefresh": true
"enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#e64340",
"navigationBarTextStyle": "white",
"backgroundColor": "#e64340"
}
......@@ -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}}">
......@@ -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">
......
......@@ -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;
......@@ -88,30 +60,14 @@
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;
......@@ -119,10 +75,6 @@
overflow: hidden;
color: #e64340;
}
.notice-box .more {
color: #666;
font-size: 24rpx;
}
.container {
background-color: #fff;
......@@ -169,6 +121,8 @@
.swiper-container .swiper1 image {
width: 750rpx;
height: 375rpx;
/* margin: 8rpx 15rpx; */
/* border-radius: 16rpx; */
}
::-webkit-scrollbar {
width: 0;
......
......@@ -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" />
......
{
"navigationBarTitleText": "搜索一下"
"navigationBarTitleText": "搜一搜"
}
\ No newline at end of file
......@@ -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": {},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册