Commit 0b6927e3 by 杨北旺

合并代码

2 parents f42ab85f 6ad1666f
Showing 148 changed files with 11056 additions and 406 deletions
...@@ -111,10 +111,17 @@ const defaultMerchantId = { ...@@ -111,10 +111,17 @@ const defaultMerchantId = {
uat: '44210895', uat: '44210895',
prod: '44189923' prod: '44189923'
}[target[index]] }[target[index]]
const CONFIG_ENV_MAP={
'1':'develope',
'2':'test',
'3':'production'
}
module.exports = { module.exports = {
index, index,
domain, domain,
pathEnum, pathEnum,
secretKey, secretKey,
defaultMerchantId defaultMerchantId,
env:CONFIG_ENV_MAP[index]
} }
import api from "../request/http"; import api from '../request/http'
const path = 'scrm.api.coupon.'
const ghPath = 'scrm.api.carlife.cgacar.'
module.exports = { module.exports = {
/**获取卡券列表 */ /**获取卡券列表 */
getCardData(data) { getCardData(data) {
return api.post({ return api.post({
method: `${path}app.list`, method: `scrm.api.coupon.app.list`,
...data ...data
// discountTypes: [3, 7] // discountTypes: [3, 7]
}) })
}, },
//获取领券中心优惠券列表
getCarCenterdData(data){
return api.post({
method: `${path}list.couponCenterList`,
...data
})
},
/**获取卡券数量 */ /**获取卡券数量 */
getCouponNum() { getCouponNum() {
return api.post({ return api.post({
...@@ -26,77 +17,43 @@ module.exports = { ...@@ -26,77 +17,43 @@ module.exports = {
}, },
/**获取首页可以领取的券 */ /**获取首页可以领取的券 */
getHomeCardData(data) { getHomeCardData(data) {
let merchantId = wx.$storage.get('srcm_shopmall_merchant_id') let {merchantId} = wx.p.storage.get('merchant_info')
if (merchantId) { if (merchantId) {
merchantId = Number(JSON.parse(merchantId)) merchantId = Number(JSON.parse(merchantId))
data.merchantId = merchantId data.merchantId = merchantId
} }
if (merchantId) {
data.merchantId = merchantId
}
return api.post({ return api.post({
method: `${path}list.merchant.account`, method: `scrm.api.coupon.list.merchant.account`,
...data ...data
}) })
}, },
/**领取优惠券 */ /**领取优惠券 */
toReciveCard(data) { toReciveCard(data) {
let {
merchantId
} = wx.p.storage.get('merchant_info')
if (merchantId) {
merchantId = Number(JSON.parse(merchantId))
data.merchantId = merchantId
}
return api.post({ return api.post({
method: `${path}customer.receive`, method: `scrm.api.coupon.customer.receive`,
...data, ...data,
receiveWay: 1,
receiveSource: 3 receiveSource: 3
}) })
}, },
/**卡券详情 */ /**卡券详情 */
couponsDetail(data) { couponsDetail(data) {
return api.post({ return api.post({
method: `${path}verification.code.detail`, method: `scrm.api.coupon.verification.code.detail`,
...data
})
},
/**广汇卡券 卡券全部列表 */
ghCouponsData() {
return api.post({
method: `${ghPath}coupon.list.benefits`
})
},
/**广汇卡券 抵用记录列表 */
ghDealNote() {
return api.post({
method: `${ghPath}coupon.list.credit.cards`
})
},
/**广汇卡券 发布确认列表 */
ghDealPublish() {
return api.post({
method: `${ghPath}coupon.list.card.deal`
})
},
/**广汇卡券 抵用确认列表 */
ghDealResist() {
return api.post({
method: `${ghPath}coupon.list.resist.deal`
})
},
/**抵用确认提交 */
ghSumbitResist(data) {
return api.post({
method: `${ghPath}coupon.resist.deal`,
...data
})
},
/**发布确认提交 */
ghSumbitPublish(data) {
return api.post({
method: `${ghPath}coupon.card.deal`,
...data ...data
}) })
}, },
/**免费领取体验卡 */ /**免费领取体验卡 */
tolqFreecard(data) { tolqFreecard(data) {
return api.post( return api.post({
{
method: `scrm.api.equity.h5.free.card.receive`, method: `scrm.api.equity.h5.free.card.receive`,
...data ...data
}, },
...@@ -113,15 +70,14 @@ module.exports = { ...@@ -113,15 +70,14 @@ module.exports = {
/** 获取企微分享优惠卷信息 */ /** 获取企微分享优惠卷信息 */
getCouponInfo(data) { getCouponInfo(data) {
return api.post({ return api.post({
method: `${path}share.info`, method: `scrm.api.coupon.share.info`,
...data ...data
}) })
}, },
/**领取优惠券 */ /**领取优惠券 */
receiveCoupon(data) { receiveCoupon(data) {
return api.post( return api.post({
{ method: `scrm.api.coupon.share.receive`,
method: `${path}share.receive`,
...data, ...data,
receiveSource: 4 receiveSource: 4
}, },
...@@ -183,5 +139,21 @@ module.exports = { ...@@ -183,5 +139,21 @@ module.exports = {
method: `scrm.api.coupon.detail`, method: `scrm.api.coupon.detail`,
...data ...data
}) })
} },
// 领取发现模块的优惠券
toReciveDiscoverCard(data) {
let {
merchantId
} = wx.p.storage.get('merchant_info')
if (merchantId) {
merchantId = Number(JSON.parse(merchantId))
data.merchantId = merchantId
}
return api.post({
method: `scrm.api.coupon.customer.receive`,
...data,
receiveWay: 9,
receiveSource: 3
})
},
} }
...@@ -5,8 +5,10 @@ import homeApi from './home' ...@@ -5,8 +5,10 @@ import homeApi from './home'
import discoveryApi from './discovery' import discoveryApi from './discovery'
import shopmallApi from './shopmall' import shopmallApi from './shopmall'
import mineApi from './mine' import mineApi from './mine'
import equityApi from './equity' import systemApi from './system'
import couponsApi from './coupons' import couponsApi from './coupons'
import equityApi from './equity'
module.exports = { module.exports = {
wechatApi, wechatApi,
entmicroApi, entmicroApi,
...@@ -15,6 +17,7 @@ module.exports = { ...@@ -15,6 +17,7 @@ module.exports = {
discoveryApi, discoveryApi,
shopmallApi, shopmallApi,
mineApi, mineApi,
equityApi, systemApi,
couponsApi couponsApi,
equityApi
} }
\ No newline at end of file \ No newline at end of file
...@@ -54,4 +54,20 @@ module.exports = { ...@@ -54,4 +54,20 @@ module.exports = {
getUserAddressDefault() { getUserAddressDefault() {
return api.fetch('scrm.api.carlife.weapp.userAddress.getDefault') return api.fetch('scrm.api.carlife.weapp.userAddress.getDefault')
}, },
/**. 分页查询订单 */
getOrderList(data) {
return api.post({
method: `scrm.api.shopmall.weapp.order.page`,
pageSize: 99999,
...data
})
},
/**获取订单状态数量 */
getOrderNumberList(data) {
return api.post({
method: 'scrm.api.shopmall.weapp.order.statis',
...data
})
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -45,8 +45,8 @@ module.exports = { ...@@ -45,8 +45,8 @@ module.exports = {
}) })
}, },
/**购物车结算 */ /**购物车结算 */
settlementShoppingcart(data) { settlementShoppingcart(data) {
return api.post({ return api.post({
method: `scrm.api.shopmall.weapp.shoppingcart.settlement`, method: `scrm.api.shopmall.weapp.shoppingcart.settlement`,
...data ...data
...@@ -67,4 +67,51 @@ module.exports = { ...@@ -67,4 +67,51 @@ module.exports = {
...data ...data
}) })
}, },
/**订单详情 */
getOrderDetail(orderCode) {
return api.post({
method: `scrm.api.shopmall.weapp.order.detail`,
orderCode
})
},
/**获取订单的售后详情 */
getOrderRefundDetail(orderCode) {
return api.post({
method: `scrm.api.shopmall.weapp.orderRefund.detail`,
orderCode
})
},
/**活动详情 */
getActivityDetail(id) {
return api.fetch('scrm.api.shopmall.weapp.activity.detail', {
id
})
},
/** 根据商品ID获取商品 */
getGoodsDetail(id) {
return api.fetch('scrm.api.shopmall.weapp.goods.getById', {
id,
viewAmount: true
})
},
/** 获取商品关联优惠券列表 */
getGoodscouponList(data) {
return api.fetch('scrm.api.shopmall.weapp.goods.user.coupons.get', data)
},
/** 领取商品详情优惠券 */
getCoupon(data) {
return api.fetch('scrm.api.coupon.customer.receive', data)
},
/**根据规格值组合获取规格组合库存及零售价 */
getGoodsSpecificationExtra(data) {
return api.post({
method: `scrm.api.shopmall.weapp.goods.getGoodsSpecificationExtra`,
...data
})
},
} }
\ No newline at end of file \ No newline at end of file
import http from "../request/http";
import { env } from "../env/index";
const serverConfig = {
mockRequestCount: null,
mockTimer: {},
mockCache: null,
};
const configModule = 'mini-hmd'
const configUrl = `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=${configModule}&env=${env}`;
/**获取mock数据 */
const getMockData = async () => {
const MOCKDATA = wx.p.storage.get("mock_data");
try {
if (MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
return Promise.resolve(MOCKDATA);
} else {
if (!serverConfig.mockRequestCount) {
serverConfig.mockCache = null;
serverConfig.mockRequestCount = Date.now();
const data = await http.wx_request({ url:configUrl });;
data.createTime = Date.now();
serverConfig.mockCache = data;
wx.p.storage.set("mock_data", data);
return Promise.resolve(data);
} else {
const key = Date.now();
return new Promise((resolve) => {
serverConfig.mockTimer[key] = setInterval(() => {
if (serverConfig.mockCache) {
clearInterval(serverConfig.mockTimer[key]);
serverConfig.mockRequestCount = null;
resolve(serverConfig.mockCache);
}
}, 1e3);
});
}
}
} catch (error) {
if (serverConfig.mockTimer[key]) clearInterval(serverConfig.mockTimer[key]);
serverConfig.mockRequestCount = null;
return Promise.reject(error);
}
};
// 图片版本号
const getImageVersion = async () => {
const accountInfo = await getMockData()
return accountInfo?.version || Date.now()
}
module.exports={
getImageVersion
}
\ No newline at end of file \ No newline at end of file
import http from '../request/http' import http from '../request/http'
// const { appId } = wx.getAccountInfoSync().miniProgram const { appId } = wx.getAccountInfoSync().miniProgram
import {
appId
} from '~/utils/constants'
let loginCount = null, let loginCount = null,
loginCache = null, loginCache = null,
loginTimer = null loginTimer = null
......
import sign from './sign.js'
import { import {
defaultMerchantId, defaultMerchantId,
secretKey, secretKey,
pathEnum, pathEnum,
domain, domain,
index, } from '../env/index'
sign
} from './sign.js'
let INTERRUPT = false
/**接口 */ /**接口 */
class Request { class Request {
get(params, returnAll = false) { get(params, returnAll = false) {
...@@ -15,15 +13,36 @@ class Request { ...@@ -15,15 +13,36 @@ class Request {
post(params, returnAll = false) { post(params, returnAll = false) {
return this.request('POST', params, returnAll) return this.request('POST', params, returnAll)
} }
fetch(method,data, returnAll = true){ fetch(method, data, returnAll = true) {
return this.post( return this.post({
{
method, method,
...data, ...data,
}, },
returnAll returnAll
); );
} }
wx_request({
url,
method = 'GET',
data = {},
header = {},
dataType = 'json',
responseType = "text"
}) {
return new Promise((resolve) => {
wx.request({
url,
data,
method,
header,
dataType,
responseType,
success(response) {
resolve(response.data)
}
})
})
}
reportTrack(params) { reportTrack(params) {
return this.request('POST', params, true) return this.request('POST', params, true)
} }
...@@ -32,7 +51,9 @@ class Request { ...@@ -32,7 +51,9 @@ class Request {
wx.showNavigationBarLoading() wx.showNavigationBarLoading()
let header = RequestMethods === 'POST' ? { let header = RequestMethods === 'POST' ? {
'content-type': 'application/x-www-form-urlencoded' 'content-type': 'application/x-www-form-urlencoded'
} : {'Cache-Control': 'no-cache'} } : {
'Cache-Control': 'no-cache'
}
header.merchantId = defaultMerchantId header.merchantId = defaultMerchantId
let projectName = this.getRopProject(params.method) let projectName = this.getRopProject(params.method)
if (!projectName) projectName = this.getRopProject(params.method) if (!projectName) projectName = this.getRopProject(params.method)
...@@ -60,21 +81,9 @@ class Request { ...@@ -60,21 +81,9 @@ class Request {
} }
if (code == 20 || code == 21) { if (code == 20 || code == 21) {
wx.hideLoading() wx.hideLoading()
const thisPage = wx.p.router.getPageInstance() return wx.reLaunch({
if (thisPage && thisPage.pageRefresh) thisPage.pageRefresh() url: '/pages/loading/loading'
if (!wx.p.authStatus) { })
if (INTERRUPT) return
INTERRUPT = true
wx.showLoading()
getApp().login().then(() => {
if (thisPage.init && thisPage.data.userInfo) thisPage.init()
if (thisPage.loginCallBack && thisPage.data.userInfo) thisPage.loginCallBack(thisPage.data.userInfo)
if (thisPage.onRoute) thisPage.onRoute()
thisPage.onLoad()
thisPage.onShow()
INTERRUPT = false
})
}
} else { } else {
if (code == '0') { if (code == '0') {
resolve(data.data) resolve(data.data)
...@@ -136,22 +145,5 @@ class Request { ...@@ -136,22 +145,5 @@ class Request {
const projectName = method.split('.')[2] const projectName = method.split('.')[2]
return projectName return projectName
} }
getMock() {
let url = 'https://oss-config.dev.glsx.com.cn/mock/6264ff4760f415276f6dfe62/aicard-config'
if (index == 3 || index == 4) url = 'https://oss-config.test.glsx.com.cn/mock/6274e3050da5034a58680aa6/aicard-config'
return new Promise((resolve) => {
wx.request({
url,
data: {},
method: 'GET',
header: {},
dataType: 'json',
responseType: 'text',
success(response) {
resolve(response.data)
}
})
})
}
} }
export default new Request() export default new Request()
\ No newline at end of file \ No newline at end of file
import sha1 from '../../lib/sha1' import {sha1,qs} from '../../lib/index'
import qs from '../../lib/qs'
import environment from '../env/index.js'
const sign = (params, secret, noSignAttr = []) => { const sign = (params, secret, noSignAttr = []) => {
delete params.sign delete params.sign
var objStr = qs.stringify(params, { var objStr = qs.stringify(params, {
...@@ -33,8 +31,4 @@ const sign = (params, secret, noSignAttr = []) => { ...@@ -33,8 +31,4 @@ const sign = (params, secret, noSignAttr = []) => {
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase() realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj return realObj
} }
module.exports = {
...environment,
sign
}
\ No newline at end of file \ No newline at end of file
export default sign
\ No newline at end of file \ No newline at end of file
// app.js // app.js
// 初始化sentry // 初始化sentry
// import sentryInit from '~/utils/sentryConfig/sentryInit' import sentryInit from "~/utils/sentryConfig/sentryInit";
// sentryInit() sentryInit();
import api from './api/index' import api from "./api/index";
import {router} from './router/index' import { router } from "./router/index";
// 判断小程序是否需要更新 // 判断小程序是否需要更新
import getUpdateManager from './lib/wxUpdateManager' import { getUpdateManager } from "./lib/index";
import utils from './utils/index' import utils from "./utils/index";
// 埋点 有需要再引入 // 埋点 有需要再引入
// import './utils/track/Track' // import './utils/track/Track'
App({ App({
onLaunch(options) { onLaunch(options) {
getUpdateManager() getUpdateManager();
/**挂载到wx对象 */ /**挂载到wx对象 */
wx.p={ wx.p = {
authStatus:false, authStatus: false,
...utils, ...utils,
api, api,
router, router,
storage:new utils.cache.Storage(), storage: new utils.cache.Storage(),
} };
// 存储设备信息 // 存储设备信息
utils.cache.storageApi.setSystem_info() utils.cache.storageApi.setSystem_info();
}, },
/**页面不存在时触发 */ /**页面不存在时触发 */
onPageNotFound(e) { onPageNotFound(e) {
wx.p.router.goHome() wx.p.router.goHome();
}, },
onHide() {}, onHide() {},
globalData: { globalData: {
ROUTE_QUERY:{} ROUTE_QUERY: {},
} },
}) });
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
{ {
"pagePath": "pages/tab/equity/index", "pagePath": "pages/tab/equity/index",
"text": "权益", "text": "权益",
"iconPath": "assets/images/mall.png", "iconPath": "assets/images/equity.png",
"selectedIconPath": "assets/images/mall_active.png" "selectedIconPath": "assets/images/equity_active.png"
}, },
{ {
"pagePath": "pages/tab/mall/index", "pagePath": "pages/tab/mall/index",
...@@ -82,7 +82,9 @@ ...@@ -82,7 +82,9 @@
"pages": [ "pages": [
"pages/index/index", "pages/index/index",
"pages/shoppingCart/shoppingCart", "pages/shoppingCart/shoppingCart",
"pages/pay/pay" "pages/pay/pay",
"pages/detail/detail",
"pages/search/search"
] ]
}, },
{ {
...@@ -91,15 +93,29 @@ ...@@ -91,15 +93,29 @@
"pages/index/index", "pages/index/index",
"pages/setting/index", "pages/setting/index",
"pages/address/index/index", "pages/address/index/index",
"pages/address/detail/detail" "pages/address/detail/detail",
"pages/order/index/index",
"pages/order/detail/detail",
"pages/order/complete/complete",
"pages/order/afterSale_step_one/afterSale_step_one",
"pages/order/afterSale_step_two/afterSale_step_two",
"pages/order/afterSale_step_three/afterSale_step_three",
"pages/order/afterSaleDetail/afterSaleDetail",
"pages/coupon/index/index",
"pages/coupon/success/success",
"pages/coupon/center/center",
"pages/coupon/detail/detail",
"pages/coupon/recommend/recommend",
"pages/coupon/usedDetail/usedDetail"
] ]
} }
], ],
"usingComponents": { "usingComponents": {
"calendar": "/components/Calendar/Calendar",
"navigation-bar": "/components/NavigationBar/NavigationBar", "navigation-bar": "/components/NavigationBar/NavigationBar",
"glsx-image": "/components/image/index", "glsx-image": "/components/image/index",
"authorize": "/components/Authorize/Authorize" "authorize": "/components/Authorize/Authorize",
"popup": "/components/Popup/Popup",
"goods-action": "/components/GoodsAction/GoodsAction"
}, },
"style": "v2", "style": "v2",
"resolveAlias": { "resolveAlias": {
......
// components/GoodsAction/GoodsAction.js
Component({
/**
* 组件的属性列表
*/
properties: {
hideShop: Boolean,
payDisabled: Boolean,
custom: Boolean,
stock: Boolean,
buyFlag: Boolean,
platformShop:Boolean
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
getViewInfo() {
wx.p.wxApi.getViewInfo(
'.goods-action-box',
res => {
this.triggerEvent('ready', res.height)
},
this
)
},
jump(e) {
let { url } = e.currentTarget.dataset
if (url == 'home') wx.p.router.goHome()
else wx.p.router.go('/packageMall/pages/shoppingCart/shoppingCart')
},
click(e) {
let { event } = e.currentTarget.dataset
this.triggerEvent('click', event)
}
},
lifetimes: {
attached() {
this.getViewInfo()
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="goods-action-box isFullSucreen">
<block wx:if="{{custom}}">
<slot></slot>
</block>
<block wx:else>
<view class="goods-action">
<view class="navigation-box">
<view class="item" bindtap="jump" data-url="home">
<view class="sprite-icon">
<glsx-image src="mall/goods-home.png"></glsx-image>
</view>
首页
</view>
<view class="item" wx:if="{{!hideShop}}" bindtap="jump">
<view class="sprite-icon" >
<glsx-image src="mall/goods-shopping.png"></glsx-image>
</view>
购物车
</view>
</view>
<view class="btn-box {{hideShop}}">
<view class="btn join text-center {{stock?'disabled':''}}" bindtap="click" data-event="join">
加入购物车
</view>
<view class="btn pay text-center {{payDisabled && hideShop?'disabled':''}} {{stock?'disabled':''}} {{buyFlag?'disabled':''}}" bindtap="click" data-event="pay">
立即购买
</view>
</view>
</view>
</block>
</view>
\ No newline at end of file \ No newline at end of file
/* components/GoodsAction/GoodsAction.wxss */
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.goods-action-box {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #fff;
z-index: 9;
animation: show-goods-action .55s forwards;
}
@keyframes show-goods-action{
0%{
bottom: -100%;
}
100%{
bottom: 0;
}
}
.goods-action {
padding: 10rpx var(--margin);
display: flex;
align-items: center;
box-sizing: border-box;
height: 100rpx;
}
.isFullSucreen {
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.navigation-box {
display: flex;
align-items: center;
font-size: 20rpx;
justify-content: space-between;
}
.navigation-box .item{
display: flex;
flex-direction: column;
align-items: center;
margin:0 14rpx;
}
.navigation-box .sprite-icon{
width: 40rpx;
height: 40rpx;
}
.btn-box {
display: flex;
align-items: center;
margin-left: auto;
border-radius: var(--borderRadius);
overflow: hidden;
}
.btn-box .btn {
width: 258rpx;
height: 80rpx;
color: #fff;
font-size: 28rpx;
}
.btn-box .pay {
background-color: var(--btnColor);
}
.btn-box .join {
background-color: #FDC23E;
}
.btn-box.true .join{
display: none;
}
.btn-box.true .btn{
width: 588rpx;
background-color: var(--themeColor);
}
.btn-box .pay.disabled{
background-color: #B1B1B3 !important;
}
.btn-box .disabled{
background-color: #B1B1B3 !important;
}
\ No newline at end of file \ No newline at end of file
// tabWorkOrder/pages/createOrder/createOrderComponents/Popup/Popup.js // tabWorkOrder/pages/createOrder/createOrderComponents/Popup/Popup.js
import {
componentsMixin
} from '../../mixins/index'
Component({ Component({
behaviors: [componentsMixin],
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
...@@ -64,13 +60,5 @@ Component({ ...@@ -64,13 +60,5 @@ Component({
confirm() { confirm() {
this.triggerEvent('confirm') this.triggerEvent('confirm')
} }
}, }
attached() {
const {
isTab
} = wx.p.router.getRouterList().find(item => item.url === `/${wx.p.router.getPageInstance().route}`)
this.setData({
isTab
})
},
}) })
\ No newline at end of file \ No newline at end of file
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
<block wx:if="{{title}}"> <block wx:if="{{title}}">
<view class="popup-title text-center">{{title}}</view> <view class="popup-title text-center">{{title}}</view>
</block> </block>
<view class="popup-slot {{isTab && !hideTab? '': title?'isFullSucreen':'isFullSucreen-notitle'}}"> <view class="popup-slot {{title?'':'notitle' }}">
<slot></slot> <slot></slot>
</view> </view>
<view class="popup-footer {{isTab && !hideTab?'':'isFullSucreen'}}" wx:if="{{only}}"> <view class="popup-footer isFullSucreen" wx:if="{{only}}">
<view class="cancel btn text-center" bindtap="hidePopup">取消</view> <view class="cancel btn text-center" bindtap="hidePopup">取消</view>
<view class="confirm btn text-center" bindtap="confirm">确认</view> <view class="confirm btn text-center" bindtap="confirm">确认</view>
</view> </view>
<view class="popup-footer {{isTab && !hideTabb?'':'isFullSucreen'}}" wx:else> <view class="popup-footer isFullSucreen" wx:else>
<view class="confirm doubtn text-center" bindtap="confirm">确认</view> <view class="confirm doubtn text-center" bindtap="confirm">确认</view>
</view> </view>
</view> </view>
......
/* tabWorkOrder/pages/createOrder/createOrderComponents/Popup/Popup.wxss */ /* tabWorkOrder/pages/createOrder/createOrderComponents/Popup/Popup.wxss */
@import "/assets/style/common.wxss";
.popup { .popup {
position: fixed; position: fixed;
top: 0; top: 0;
...@@ -45,15 +46,14 @@ ...@@ -45,15 +46,14 @@
} }
.popup-slot { .popup-slot {
height: calc(100% - 200rpx); height: calc(100% - 200rpx - var(--constantSafeAreaInsetBottom));
height: calc(100% - 200rpx - var(--envSafeAreaInsetBottom));
} }
.popup-slot.isFullSucreen {
height: calc(100% - 258rpx);
}
.popup-slot.isFullSucreen-notitle { .popup-slot.notitle {
height: calc(100% - 158rpx); height: calc(100% - 158rpx - var(--constantSafeAreaInsetBottom));
height: calc(100% - 158rpx - var(--envSafeAreaInsetBottom));
} }
.popup-footer { .popup-footer {
...@@ -66,10 +66,6 @@ ...@@ -66,10 +66,6 @@
z-index: 2; z-index: 2;
} }
.popup-footer.isFullSucreen {
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.popup-footer .btn { .popup-footer .btn {
width: 330rpx; width: 330rpx;
......
// components/Tab/Tab.js // components/Tab/Tab.js
import {componentsMixin } from '../../mixins/index'
Component({ Component({
behaviors:[componentsMixin],
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
......
/* components/Tab/Tab.wxss */ /* components/Tab/Tab.wxss */
@import "../../common.wxss"; @import "../../assets/style/common.wxss";
.tab-box { .tab-box {
display: flex; display: flex;
......
// components/image/index.js // components/image/index.js
import { import {
IMG_URL, IMG_URL,
IMG_VERSION } from '~/config'
} from '~/utils/constants' import {
systemApi
} from '~/api/index'
Component({ Component({
externalClasses: ['custom-class', 'class'], externalClasses: ['custom-class', 'class'],
/** /**
...@@ -19,7 +21,7 @@ Component({ ...@@ -19,7 +21,7 @@ Component({
let isFullAdd = checkList.map(item => url.includes(item)).some(item => item) let isFullAdd = checkList.map(item => url.includes(item)).some(item => item)
this.setData({ this.setData({
isWebp, isWebp,
imagePath: `${isFullAdd ? '' : IMG_URL}${url}?v=` + await IMG_VERSION() imagePath: `${isFullAdd ? '' : IMG_URL}${url}?v=` + await systemApi.getImageVersion()
}) })
} }
} }
......
...@@ -10,4 +10,4 @@ export const preReleaseAppId = 'wx6e40cfb83ce4ffb1' ...@@ -10,4 +10,4 @@ export const preReleaseAppId = 'wx6e40cfb83ce4ffb1'
export const dsnUrl = 'https://44b18e4acc2e4ab18f12a69a561b55bc@sentry.glsx.com.cn/39' export const dsnUrl = 'https://44b18e4acc2e4ab18f12a69a561b55bc@sentry.glsx.com.cn/39'
// cdn图片地址 // cdn图片地址
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd' export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd/'
import sha1 from './sha1.js'
import qs from './qs'
import wxqrcode from './wxqrcode.js'
import getUpdateManager from "./wxUpdateManager";
import * as Sentry from './sentry-miniapp'
module.exports ={ sha1,qs,wxqrcode,getUpdateManager,Sentry }
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,7 @@ var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexport ...@@ -4,7 +4,7 @@ var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexport
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; }; var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } }; var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; }; var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1689247481138, function(require, module, exports) { __DEFINE__(1689250267950, function(require, module, exports) {
/* /*
* @Descripttion: api封装类 * @Descripttion: api封装类
* @version: 1.0.0 * @version: 1.0.0
...@@ -225,8 +225,8 @@ class GlMapApi { ...@@ -225,8 +225,8 @@ class GlMapApi {
} }
if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });exports.default = GlMapApi; if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });exports.default = GlMapApi;
}, function(modId) {var map = {"./request":1689247481139}; return __REQUIRE__(map[modId], modId); }) }, function(modId) {var map = {"./request":1689250267951}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1689247481139, function(require, module, exports) { __DEFINE__(1689250267951, function(require, module, exports) {
/* /*
* @Descripttion: 定义一个Request类,用于封装请求高德地图API的方法 * @Descripttion: 定义一个Request类,用于封装请求高德地图API的方法
* @version: 1.0.0 * @version: 1.0.0
...@@ -340,8 +340,8 @@ class Request { ...@@ -340,8 +340,8 @@ class Request {
} }
if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });exports.default = Request; if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });exports.default = Request;
}, function(modId) { var map = {"./lib/md5":1689247481140,"./lib/qs":1689247481141,"./constants":1689247481142,"./helper":1689247481143}; return __REQUIRE__(map[modId], modId); }) }, function(modId) { var map = {"./lib/md5":1689250267952,"./lib/qs":1689250267953,"./constants":1689250267954,"./helper":1689250267955}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1689247481140, function(require, module, exports) { __DEFINE__(1689250267952, function(require, module, exports) {
(function () { (function () {
...@@ -1017,7 +1017,7 @@ __DEFINE__(1689247481140, function(require, module, exports) { ...@@ -1017,7 +1017,7 @@ __DEFINE__(1689247481140, function(require, module, exports) {
} }
})(); })();
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1689247481141, function(require, module, exports) { __DEFINE__(1689250267953, function(require, module, exports) {
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
...@@ -1658,7 +1658,7 @@ module.exports = { ...@@ -1658,7 +1658,7 @@ module.exports = {
}); });
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1689247481142, function(require, module, exports) { __DEFINE__(1689250267954, function(require, module, exports) {
/* /*
* @Descripttion: 常量类 * @Descripttion: 常量类
* @version: 1.0.0 * @version: 1.0.0
...@@ -1671,7 +1671,7 @@ __DEFINE__(1689247481142, function(require, module, exports) { ...@@ -1671,7 +1671,7 @@ __DEFINE__(1689247481142, function(require, module, exports) {
if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });var MAP_OPTIONS = exports.MAP_OPTIONS = { domain: 'https://restapi.amap.com', KEY: '373bd88fa36ebc0247d60281386b6cec', SECRET: 'a2a93fa04721a36819d86b71cb31fe41' }; if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });var MAP_OPTIONS = exports.MAP_OPTIONS = { domain: 'https://restapi.amap.com', KEY: '373bd88fa36ebc0247d60281386b6cec', SECRET: 'a2a93fa04721a36819d86b71cb31fe41' };
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1689247481143, function(require, module, exports) { __DEFINE__(1689250267955, function(require, module, exports) {
/* /*
* @Descripttion:帮助类 * @Descripttion:帮助类
* @version: 1.0.0 * @version: 1.0.0
...@@ -1684,7 +1684,7 @@ __DEFINE__(1689247481143, function(require, module, exports) { ...@@ -1684,7 +1684,7 @@ __DEFINE__(1689247481143, function(require, module, exports) {
if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });var isMiniprogram = exports.isMiniprogram = !window; if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });var isMiniprogram = exports.isMiniprogram = !window;
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1689247481138); return __REQUIRE__(1689250267950);
})() })()
//miniprogram-npm-outsideDeps=["./stringify","./parse","./formats","./utils"] //miniprogram-npm-outsideDeps=["./stringify","./parse","./formats","./utils"]
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map
\ No newline at end of file \ No newline at end of file
module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1689250267956, function(require, module, exports) {
Object.defineProperty(exports, '__esModule', { value: true });
/**
* @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
*
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
*/
/**
* Correct the given number to specifying significant digits.
*
* @param num The input number
* @param precision An integer specifying the number of significant digits
*
* @example strip(0.09999999999999998) === 0.1 // true
*/
function strip(num, precision) {
if (precision === void 0) { precision = 15; }
return +parseFloat(Number(num).toPrecision(precision));
}
/**
* Return digits length of a number.
*
* @param num The input number
*/
function digitLength(num) {
// Get digit length of e
var eSplit = num.toString().split(/[eE]/);
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
return len > 0 ? len : 0;
}
/**
* Convert the given number to integer, support scientific notation.
* The number will be scale up if it is decimal.
*
* @param num The input number
*/
function float2Fixed(num) {
if (num.toString().indexOf('e') === -1) {
return Number(num.toString().replace('.', ''));
}
var dLen = digitLength(num);
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
}
/**
* Log a warning if the given number is out of bounds.
*
* @param num The input number
*/
function checkBoundary(num) {
if (_boundaryCheckingState) {
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
console.warn(num + " is beyond boundary when transfer to integer, the results may not be accurate");
}
}
}
/**
* Create an operation to support rest params.
*
* @param operation The original operation
*/
function createOperation(operation) {
return function () {
var nums = [];
for (var _i = 0; _i < arguments.length; _i++) {
nums[_i] = arguments[_i];
}
var first = nums[0], others = nums.slice(1);
return others.reduce(function (prev, next) { return operation(prev, next); }, first);
};
}
/**
* Accurate multiplication.
*
* @param nums The numbers to multiply
*/
var times = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
var baseNum = digitLength(num1) + digitLength(num2);
var leftValue = num1Changed * num2Changed;
checkBoundary(leftValue);
return leftValue / Math.pow(10, baseNum);
});
/**
* Accurate addition.
*
* @param nums The numbers to add
*/
var plus = createOperation(function (num1, num2) {
// 取最大的小数位
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
// 把小数都转为整数然后再计算
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
});
/**
* Accurate subtraction.
*
* @param nums The numbers to subtract
*/
var minus = createOperation(function (num1, num2) {
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
});
/**
* Accurate division.
*
* @param nums The numbers to divide
*/
var divide = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
checkBoundary(num1Changed);
checkBoundary(num2Changed);
// fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
});
/**
* Accurate rounding method.
*
* @param num The number to round
* @param decimal An integer specifying the decimal digits
*/
function round(num, decimal) {
var base = Math.pow(10, decimal);
var result = divide(Math.round(Math.abs(times(num, base))), base);
if (num < 0 && result !== 0) {
result = times(result, -1);
}
return result;
}
var _boundaryCheckingState = true;
/**
* Whether to check the bounds of number, default is enabled.
*
* @param flag The value to indicate whether is enabled
*/
function enableBoundaryChecking(flag) {
if (flag === void 0) { flag = true; }
_boundaryCheckingState = flag;
}
var index = {
strip: strip,
plus: plus,
minus: minus,
times: times,
divide: divide,
round: round,
digitLength: digitLength,
float2Fixed: float2Fixed,
enableBoundaryChecking: enableBoundaryChecking,
};
exports.strip = strip;
exports.plus = plus;
exports.minus = minus;
exports.times = times;
exports.divide = divide;
exports.round = round;
exports.digitLength = digitLength;
exports.float2Fixed = float2Fixed;
exports.enableBoundaryChecking = enableBoundaryChecking;
exports['default'] = index;
}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1689250267956);
})()
//miniprogram-npm-outsideDeps=[]
//# sourceMappingURL=index.js.map
\ No newline at end of file \ No newline at end of file
{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\n/**\r\n * @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。\r\n *\r\n * 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998\r\n */\r\n/**\r\n * Correct the given number to specifying significant digits.\r\n *\r\n * @param num The input number\r\n * @param precision An integer specifying the number of significant digits\r\n *\r\n * @example strip(0.09999999999999998) === 0.1 // true\r\n */\r\nfunction strip(num, precision) {\r\n if (precision === void 0) { precision = 15; }\r\n return +parseFloat(Number(num).toPrecision(precision));\r\n}\r\n/**\r\n * Return digits length of a number.\r\n *\r\n * @param num The input number\r\n */\r\nfunction digitLength(num) {\r\n // Get digit length of e\r\n var eSplit = num.toString().split(/[eE]/);\r\n var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);\r\n return len > 0 ? len : 0;\r\n}\r\n/**\r\n * Convert the given number to integer, support scientific notation.\r\n * The number will be scale up if it is decimal.\r\n *\r\n * @param num The input number\r\n */\r\nfunction float2Fixed(num) {\r\n if (num.toString().indexOf('e') === -1) {\r\n return Number(num.toString().replace('.', ''));\r\n }\r\n var dLen = digitLength(num);\r\n return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);\r\n}\r\n/**\r\n * Log a warning if the given number is out of bounds.\r\n *\r\n * @param num The input number\r\n */\r\nfunction checkBoundary(num) {\r\n if (_boundaryCheckingState) {\r\n if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {\r\n console.warn(num + \" is beyond boundary when transfer to integer, the results may not be accurate\");\r\n }\r\n }\r\n}\r\n/**\r\n * Create an operation to support rest params.\r\n *\r\n * @param operation The original operation\r\n */\r\nfunction createOperation(operation) {\r\n return function () {\r\n var nums = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n nums[_i] = arguments[_i];\r\n }\r\n var first = nums[0], others = nums.slice(1);\r\n return others.reduce(function (prev, next) { return operation(prev, next); }, first);\r\n };\r\n}\r\n/**\r\n * Accurate multiplication.\r\n *\r\n * @param nums The numbers to multiply\r\n */\r\nvar times = createOperation(function (num1, num2) {\r\n var num1Changed = float2Fixed(num1);\r\n var num2Changed = float2Fixed(num2);\r\n var baseNum = digitLength(num1) + digitLength(num2);\r\n var leftValue = num1Changed * num2Changed;\r\n checkBoundary(leftValue);\r\n return leftValue / Math.pow(10, baseNum);\r\n});\r\n/**\r\n * Accurate addition.\r\n *\r\n * @param nums The numbers to add\r\n */\r\nvar plus = createOperation(function (num1, num2) {\r\n // 取最大的小数位\r\n var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));\r\n // 把小数都转为整数然后再计算\r\n return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;\r\n});\r\n/**\r\n * Accurate subtraction.\r\n *\r\n * @param nums The numbers to subtract\r\n */\r\nvar minus = createOperation(function (num1, num2) {\r\n var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));\r\n return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;\r\n});\r\n/**\r\n * Accurate division.\r\n *\r\n * @param nums The numbers to divide\r\n */\r\nvar divide = createOperation(function (num1, num2) {\r\n var num1Changed = float2Fixed(num1);\r\n var num2Changed = float2Fixed(num2);\r\n checkBoundary(num1Changed);\r\n checkBoundary(num2Changed);\r\n // fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正\r\n return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));\r\n});\r\n/**\r\n * Accurate rounding method.\r\n *\r\n * @param num The number to round\r\n * @param decimal An integer specifying the decimal digits\r\n */\r\nfunction round(num, decimal) {\r\n var base = Math.pow(10, decimal);\r\n var result = divide(Math.round(Math.abs(times(num, base))), base);\r\n if (num < 0 && result !== 0) {\r\n result = times(result, -1);\r\n }\r\n return result;\r\n}\r\nvar _boundaryCheckingState = true;\r\n/**\r\n * Whether to check the bounds of number, default is enabled.\r\n *\r\n * @param flag The value to indicate whether is enabled\r\n */\r\nfunction enableBoundaryChecking(flag) {\r\n if (flag === void 0) { flag = true; }\r\n _boundaryCheckingState = flag;\r\n}\r\nvar index = {\r\n strip: strip,\r\n plus: plus,\r\n minus: minus,\r\n times: times,\r\n divide: divide,\r\n round: round,\r\n digitLength: digitLength,\r\n float2Fixed: float2Fixed,\r\n enableBoundaryChecking: enableBoundaryChecking,\r\n};\n\nexports.strip = strip;\nexports.plus = plus;\nexports.minus = minus;\nexports.times = times;\nexports.divide = divide;\nexports.round = round;\nexports.digitLength = digitLength;\nexports.float2Fixed = float2Fixed;\nexports.enableBoundaryChecking = enableBoundaryChecking;\nexports['default'] = index;\n"]}
\ No newline at end of file \ No newline at end of file
module.exports = Behavior(
{
data: {
afterType:{
1:'我要退款退货',
2:'我要退款(无需退货)'
}
}
})
\ No newline at end of file \ No newline at end of file
module.exports = {} import kfMixin from './kfMixin'
import orderMixin from './orderMixin'
import afterSaleMixin from './afterSaleMixin'
module.exports = {
kfMixin,
orderMixin,
afterSaleMixin,
}
// const kf_list = [{
// sapCode: 5036,
// url: 'https://work.weixin.qq.com/kfid/kfc82ffd378b8649621'
// },
// {
// sapCode: 5028,
// url: 'https://work.weixin.qq.com/kfid/kfcd636da4134201fbb'
// },
// {
// sapCode: 5016,
// url: 'https://work.weixin.qq.com/kfid/kfcdef92056fc8ef091'
// },
// ]
module.exports = Behavior({
data: {},
methods: {
filterKfList(data) {
let showKF = false,
customerlist = [],
kfUrl = ''
if (data.customerServerType) {
if (data.customerServerType == 1)
customerlist[0] = {
thumbAvatar: data.customerServerAvatar,
staffName: data.customerServerName,
qrCode: data.customerServerOrCode
}
else kfUrl = data.customerServerUrl
showKF = true
}
this.setData({
showKF,
kfUrl,
customerlist
})
},
openKF(e) {
let { kfUrl, widgetStatus } = this.data
if (kfUrl)
wx.openCustomerServiceChat({
extInfo: {
url: kfUrl
},
corpId: 'wx51bda2e574d24a91',
success(res) {
console.log(res)
},
fail({ errMsg }) {
console.log(errMsg)
wx.$api.showToast(errMsg)
}
})
else
this.setData({
widgetStatus: !widgetStatus
})
}
}
})
module.exports = Behavior({
data: {
//1:待付款;2:已支付;3:已关闭;4:已发货;5:已收货;6:待发货;7:待安装;8:已安装;9:售后中;10:售后完成
statusEnum: {
1: '待付款',
2: '已支付',
3: '已关闭',
4: '已发货',
5: '已收货',
6: '待发货',
7: '待安装',
8: '已安装',
9: '售后中',
10: '售后完成'
},
/**售后状态 1:待审核;2:审核通过;3:审核不通过;4:待确认收到退货;5:退款中;6:已退款;7:退款失败;8已取消 */
afterSaleStatus: {
1: '待审核',
2: '审核通过',
3: '审核不通过',
4: '待确认收到退货',
5: '退款中',
6: '已退款',
7: '退款失败',
8: '已取消'
},
/**权益&套餐 */
cardStatus: {
0: '未支付',
1: '已支付',
2: '待收货',
3: '已完成',
4: '售后中',
5: '退款失败',
6: '已退款'
},
reStatus: {
2: '充值中',
3: '充值成功',
4: '退款中',
6: '充值失败',
}
}
})
\ No newline at end of file \ No newline at end of file
dist: trusty
language: node_js
node_js:
- 8
script:
- npm test
addons:
firefox: "49.0"
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
# number-precision [![npm version](https://badge.fury.io/js/number-precision.svg)](http://badge.fury.io/js/number-precision) [![Build Status](https://travis-ci.org/nefe/number-precision.svg)](https://travis-ci.org/nefe/number-precision) [![codecov](https://codecov.io/gh/nefe/number-precision/branch/master/graph/badge.svg)](https://codecov.io/gh/nefe/number-precision)
Perform addition, subtraction, multiplication and division operations precisely using javascript
### Why
```js
0.1 + 0.2 = 0.30000000000000004
1.0 - 0.9 = 0.09999999999999998
0.105.toFixed(2) = 0.1 // not 0.11
```
### Install
```
npm install number-precision --save
```
### Methods
```js
NP.strip(num) // strip a number to nearest right number
NP.plus(num1, num2, num3, ...) // addition, num + num2 + num3, two numbers is required at least.
NP.minus(num1, num2, num3, ...) // subtraction, num1 - num2 - num3
NP.times(num1, num2, num3, ...) // multiplication, num1 * num2 * num3
NP.divide(num1, num2, num3, ...) // division, num1 / num2 / num3
NP.round(num, ratio) // round a number based on ratio
```
### Usage
```js
import NP from 'number-precision'
NP.strip(0.09999999999999998); // = 0.1
NP.plus(0.1, 0.2); // = 0.3, not 0.30000000000000004
NP.plus(2.3, 2.4); // = 4.7, not 4.699999999999999
NP.minus(1.0, 0.9); // = 0.1, not 0.09999999999999998
NP.times(3, 0.3); // = 0.9, not 0.8999999999999999
NP.times(0.362, 100); // = 36.2, not 36.199999999999996
NP.divide(1.21, 1.1); // = 1.1, not 1.0999999999999999
NP.round(0.105, 2); // = 0.11, not 0.1
```
PS: If you want to get rid of `XXX is beyond boundary when transfer to integer, the results may not be accurate`, use this at the beginning of your app to turn off boundary checking.
```js
NP.enableBoundaryChecking(false); // default param is true
```
### License
MIT
"use strict";
/**
* @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
*
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.enableBoundaryChecking = exports.float2Fixed = exports.digitLength = exports.round = exports.divide = exports.times = exports.minus = exports.plus = exports.strip = void 0;
/**
* Correct the given number to specifying significant digits.
*
* @param num The input number
* @param precision An integer specifying the number of significant digits
*
* @example strip(0.09999999999999998) === 0.1 // true
*/
function strip(num, precision) {
if (precision === void 0) { precision = 15; }
return +parseFloat(Number(num).toPrecision(precision));
}
exports.strip = strip;
/**
* Return digits length of a number.
*
* @param num The input number
*/
function digitLength(num) {
// Get digit length of e
var eSplit = num.toString().split(/[eE]/);
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
return len > 0 ? len : 0;
}
exports.digitLength = digitLength;
/**
* Convert the given number to integer, support scientific notation.
* The number will be scale up if it is decimal.
*
* @param num The input number
*/
function float2Fixed(num) {
if (num.toString().indexOf('e') === -1) {
return Number(num.toString().replace('.', ''));
}
var dLen = digitLength(num);
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
}
exports.float2Fixed = float2Fixed;
/**
* Log a warning if the given number is out of bounds.
*
* @param num The input number
*/
function checkBoundary(num) {
if (_boundaryCheckingState) {
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
console.warn(num + " is beyond boundary when transfer to integer, the results may not be accurate");
}
}
}
/**
* Create an operation to support rest params.
*
* @param operation The original operation
*/
function createOperation(operation) {
return function () {
var nums = [];
for (var _i = 0; _i < arguments.length; _i++) {
nums[_i] = arguments[_i];
}
var first = nums[0], others = nums.slice(1);
return others.reduce(function (prev, next) { return operation(prev, next); }, first);
};
}
/**
* Accurate multiplication.
*
* @param nums The numbers to multiply
*/
var times = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
var baseNum = digitLength(num1) + digitLength(num2);
var leftValue = num1Changed * num2Changed;
checkBoundary(leftValue);
return leftValue / Math.pow(10, baseNum);
});
exports.times = times;
/**
* Accurate addition.
*
* @param nums The numbers to add
*/
var plus = createOperation(function (num1, num2) {
// 取最大的小数位
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
// 把小数都转为整数然后再计算
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
});
exports.plus = plus;
/**
* Accurate subtraction.
*
* @param nums The numbers to subtract
*/
var minus = createOperation(function (num1, num2) {
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
});
exports.minus = minus;
/**
* Accurate division.
*
* @param nums The numbers to divide
*/
var divide = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
checkBoundary(num1Changed);
checkBoundary(num2Changed);
// fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
});
exports.divide = divide;
/**
* Accurate rounding method.
*
* @param num The number to round
* @param decimal An integer specifying the decimal digits
*/
function round(num, decimal) {
var base = Math.pow(10, decimal);
var result = divide(Math.round(Math.abs(times(num, base))), base);
if (num < 0 && result !== 0) {
result = times(result, -1);
}
return result;
}
exports.round = round;
var _boundaryCheckingState = true;
/**
* Whether to check the bounds of number, default is enabled.
*
* @param flag The value to indicate whether is enabled
*/
function enableBoundaryChecking(flag) {
if (flag === void 0) { flag = true; }
_boundaryCheckingState = flag;
}
exports.enableBoundaryChecking = enableBoundaryChecking;
exports.default = {
strip: strip,
plus: plus,
minus: minus,
times: times,
divide: divide,
round: round,
digitLength: digitLength,
float2Fixed: float2Fixed,
enableBoundaryChecking: enableBoundaryChecking,
};
//# sourceMappingURL=index.js.map
\ No newline at end of file \ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH;;;;;;;GAOG;AACH,SAAS,KAAK,CAAC,GAAe,EAAE,SAAc;IAAd,0BAAA,EAAA,cAAc;IAC5C,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACzD,CAAC;AAuIQ,sBAAK;AArId;;;;GAIG;AACH,SAAS,WAAW,CAAC,GAAe;IAClC,wBAAwB;IACxB,IAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvE,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AA2HkD,kCAAW;AAzH9D;;;;;GAKG;AACH,SAAS,WAAW,CAAC,GAAe;IAClC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QACtC,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;KAChD;IACD,IAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1E,CAAC;AA6G+D,kCAAW;AA3G3E;;;;GAIG;AACH,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,sBAAsB,EAAE;QAC1B,IAAI,GAAG,GAAG,MAAM,CAAC,gBAAgB,IAAI,GAAG,GAAG,MAAM,CAAC,gBAAgB,EAAE;YAClE,OAAO,CAAC,IAAI,CAAI,GAAG,kFAA+E,CAAC,CAAC;SACrG;KACF;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,SAAqD;IAC5E,OAAO;QAAC,cAAqB;aAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;YAArB,yBAAqB;;QACpB,IAAA,KAAK,GAAe,IAAI,GAAnB,EAAK,MAAM,GAAI,IAAI,SAAR,CAAS;QAChC,OAAO,MAAM,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,IAAI,IAAK,OAAA,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EAArB,CAAqB,EAAE,KAAK,CAAW,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,IAAM,KAAK,GAAG,eAAe,CAAC,UAAC,IAAI,EAAE,IAAI;IACvC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtD,IAAM,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;IAE5C,aAAa,CAAC,SAAS,CAAC,CAAC;IAEzB,OAAO,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAoE0B,sBAAK;AAlElC;;;;GAIG;AACH,IAAM,IAAI,GAAG,eAAe,CAAC,UAAC,IAAI,EAAE,IAAI;IACtC,UAAU;IACV,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7E,gBAAgB;IAChB,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;AACjE,CAAC,CAAC,CAAC;AAwDa,oBAAI;AAtDpB;;;;GAIG;AACH,IAAM,KAAK,GAAG,eAAe,CAAC,UAAC,IAAI,EAAE,IAAI;IACvC,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7E,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;AACjE,CAAC,CAAC,CAAC;AA8CmB,sBAAK;AA5C3B;;;;GAIG;AACH,IAAM,MAAM,GAAG,eAAe,CAAC,UAAC,IAAI,EAAE,IAAI;IACxC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAEtC,aAAa,CAAC,WAAW,CAAC,CAAC;IAC3B,aAAa,CAAC,WAAW,CAAC,CAAC;IAE3B,qDAAqD;IACrD,OAAO,KAAK,CAAC,WAAW,GAAG,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC;AA8BiC,wBAAM;AA5B1C;;;;;GAKG;AACH,SAAS,KAAK,CAAC,GAAe,EAAE,OAAe;IAC7C,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACnC,IAAI,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAElE,IAAI,GAAG,GAAG,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE;QAC3B,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;KAC5B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAa2C,sBAAK;AAXjD,IAAI,sBAAsB,GAAG,IAAI,CAAC;AAElC;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,IAAW;IAAX,qBAAA,EAAA,WAAW;IACzC,sBAAsB,GAAG,IAAI,CAAC;AAChC,CAAC;AAE4E,wDAAsB;AAEnG,kBAAe;IACb,KAAK,OAAA;IACL,IAAI,MAAA;IACJ,KAAK,OAAA;IACL,KAAK,OAAA;IACL,MAAM,QAAA;IACN,KAAK,OAAA;IACL,WAAW,aAAA;IACX,WAAW,aAAA;IACX,sBAAsB,wBAAA;CACvB,CAAC"}
\ No newline at end of file \ No newline at end of file
/**
* @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
*
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
*/
declare type NumberType = number | string;
/**
* Correct the given number to specifying significant digits.
*
* @param num The input number
* @param precision An integer specifying the number of significant digits
*
* @example strip(0.09999999999999998) === 0.1 // true
*/
declare function strip(num: NumberType, precision?: number): number;
/**
* Return digits length of a number.
*
* @param num The input number
*/
declare function digitLength(num: NumberType): number;
/**
* Convert the given number to integer, support scientific notation.
* The number will be scale up if it is decimal.
*
* @param num The input number
*/
declare function float2Fixed(num: NumberType): number;
/**
* Accurate multiplication.
*
* @param nums The numbers to multiply
*/
declare const times: (...nums: NumberType[]) => number;
/**
* Accurate addition.
*
* @param nums The numbers to add
*/
declare const plus: (...nums: NumberType[]) => number;
/**
* Accurate subtraction.
*
* @param nums The numbers to subtract
*/
declare const minus: (...nums: NumberType[]) => number;
/**
* Accurate division.
*
* @param nums The numbers to divide
*/
declare const divide: (...nums: NumberType[]) => number;
/**
* Accurate rounding method.
*
* @param num The number to round
* @param decimal An integer specifying the decimal digits
*/
declare function round(num: NumberType, decimal: number): number;
/**
* Whether to check the bounds of number, default is enabled.
*
* @param flag The value to indicate whether is enabled
*/
declare function enableBoundaryChecking(flag?: boolean): void;
export { strip, plus, minus, times, divide, round, digitLength, float2Fixed, enableBoundaryChecking };
declare const _default: {
strip: typeof strip;
plus: (...nums: NumberType[]) => number;
minus: (...nums: NumberType[]) => number;
times: (...nums: NumberType[]) => number;
divide: (...nums: NumberType[]) => number;
round: typeof round;
digitLength: typeof digitLength;
float2Fixed: typeof float2Fixed;
enableBoundaryChecking: typeof enableBoundaryChecking;
};
export default _default;
/**
* @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
*
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
*/
/**
* Correct the given number to specifying significant digits.
*
* @param num The input number
* @param precision An integer specifying the number of significant digits
*
* @example strip(0.09999999999999998) === 0.1 // true
*/
function strip(num, precision) {
if (precision === void 0) { precision = 15; }
return +parseFloat(Number(num).toPrecision(precision));
}
/**
* Return digits length of a number.
*
* @param num The input number
*/
function digitLength(num) {
// Get digit length of e
var eSplit = num.toString().split(/[eE]/);
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
return len > 0 ? len : 0;
}
/**
* Convert the given number to integer, support scientific notation.
* The number will be scale up if it is decimal.
*
* @param num The input number
*/
function float2Fixed(num) {
if (num.toString().indexOf('e') === -1) {
return Number(num.toString().replace('.', ''));
}
var dLen = digitLength(num);
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
}
/**
* Log a warning if the given number is out of bounds.
*
* @param num The input number
*/
function checkBoundary(num) {
if (_boundaryCheckingState) {
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
console.warn(num + " is beyond boundary when transfer to integer, the results may not be accurate");
}
}
}
/**
* Create an operation to support rest params.
*
* @param operation The original operation
*/
function createOperation(operation) {
return function () {
var nums = [];
for (var _i = 0; _i < arguments.length; _i++) {
nums[_i] = arguments[_i];
}
var first = nums[0], others = nums.slice(1);
return others.reduce(function (prev, next) { return operation(prev, next); }, first);
};
}
/**
* Accurate multiplication.
*
* @param nums The numbers to multiply
*/
var times = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
var baseNum = digitLength(num1) + digitLength(num2);
var leftValue = num1Changed * num2Changed;
checkBoundary(leftValue);
return leftValue / Math.pow(10, baseNum);
});
/**
* Accurate addition.
*
* @param nums The numbers to add
*/
var plus = createOperation(function (num1, num2) {
// 取最大的小数位
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
// 把小数都转为整数然后再计算
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
});
/**
* Accurate subtraction.
*
* @param nums The numbers to subtract
*/
var minus = createOperation(function (num1, num2) {
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
});
/**
* Accurate division.
*
* @param nums The numbers to divide
*/
var divide = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
checkBoundary(num1Changed);
checkBoundary(num2Changed);
// fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
});
/**
* Accurate rounding method.
*
* @param num The number to round
* @param decimal An integer specifying the decimal digits
*/
function round(num, decimal) {
var base = Math.pow(10, decimal);
var result = divide(Math.round(Math.abs(times(num, base))), base);
if (num < 0 && result !== 0) {
result = times(result, -1);
}
return result;
}
var _boundaryCheckingState = true;
/**
* Whether to check the bounds of number, default is enabled.
*
* @param flag The value to indicate whether is enabled
*/
function enableBoundaryChecking(flag) {
if (flag === void 0) { flag = true; }
_boundaryCheckingState = flag;
}
var index = {
strip: strip,
plus: plus,
minus: minus,
times: times,
divide: divide,
round: round,
digitLength: digitLength,
float2Fixed: float2Fixed,
enableBoundaryChecking: enableBoundaryChecking,
};
export { strip, plus, minus, times, divide, round, digitLength, float2Fixed, enableBoundaryChecking };
export default index;
var NP = (function (exports) {
'use strict';
/**
* @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
*
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
*/
/**
* Correct the given number to specifying significant digits.
*
* @param num The input number
* @param precision An integer specifying the number of significant digits
*
* @example strip(0.09999999999999998) === 0.1 // true
*/
function strip(num, precision) {
if (precision === void 0) { precision = 15; }
return +parseFloat(Number(num).toPrecision(precision));
}
/**
* Return digits length of a number.
*
* @param num The input number
*/
function digitLength(num) {
// Get digit length of e
var eSplit = num.toString().split(/[eE]/);
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
return len > 0 ? len : 0;
}
/**
* Convert the given number to integer, support scientific notation.
* The number will be scale up if it is decimal.
*
* @param num The input number
*/
function float2Fixed(num) {
if (num.toString().indexOf('e') === -1) {
return Number(num.toString().replace('.', ''));
}
var dLen = digitLength(num);
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
}
/**
* Log a warning if the given number is out of bounds.
*
* @param num The input number
*/
function checkBoundary(num) {
if (_boundaryCheckingState) {
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
console.warn(num + " is beyond boundary when transfer to integer, the results may not be accurate");
}
}
}
/**
* Create an operation to support rest params.
*
* @param operation The original operation
*/
function createOperation(operation) {
return function () {
var nums = [];
for (var _i = 0; _i < arguments.length; _i++) {
nums[_i] = arguments[_i];
}
var first = nums[0], others = nums.slice(1);
return others.reduce(function (prev, next) { return operation(prev, next); }, first);
};
}
/**
* Accurate multiplication.
*
* @param nums The numbers to multiply
*/
var times = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
var baseNum = digitLength(num1) + digitLength(num2);
var leftValue = num1Changed * num2Changed;
checkBoundary(leftValue);
return leftValue / Math.pow(10, baseNum);
});
/**
* Accurate addition.
*
* @param nums The numbers to add
*/
var plus = createOperation(function (num1, num2) {
// 取最大的小数位
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
// 把小数都转为整数然后再计算
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
});
/**
* Accurate subtraction.
*
* @param nums The numbers to subtract
*/
var minus = createOperation(function (num1, num2) {
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
});
/**
* Accurate division.
*
* @param nums The numbers to divide
*/
var divide = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
checkBoundary(num1Changed);
checkBoundary(num2Changed);
// fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
});
/**
* Accurate rounding method.
*
* @param num The number to round
* @param decimal An integer specifying the decimal digits
*/
function round(num, decimal) {
var base = Math.pow(10, decimal);
var result = divide(Math.round(Math.abs(times(num, base))), base);
if (num < 0 && result !== 0) {
result = times(result, -1);
}
return result;
}
var _boundaryCheckingState = true;
/**
* Whether to check the bounds of number, default is enabled.
*
* @param flag The value to indicate whether is enabled
*/
function enableBoundaryChecking(flag) {
if (flag === void 0) { flag = true; }
_boundaryCheckingState = flag;
}
var index = {
strip: strip,
plus: plus,
minus: minus,
times: times,
divide: divide,
round: round,
digitLength: digitLength,
float2Fixed: float2Fixed,
enableBoundaryChecking: enableBoundaryChecking,
};
exports.strip = strip;
exports.plus = plus;
exports.minus = minus;
exports.times = times;
exports.divide = divide;
exports.round = round;
exports.digitLength = digitLength;
exports.float2Fixed = float2Fixed;
exports.enableBoundaryChecking = enableBoundaryChecking;
exports['default'] = index;
return exports;
}({}));
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
*
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
*/
/**
* Correct the given number to specifying significant digits.
*
* @param num The input number
* @param precision An integer specifying the number of significant digits
*
* @example strip(0.09999999999999998) === 0.1 // true
*/
function strip(num, precision) {
if (precision === void 0) { precision = 15; }
return +parseFloat(Number(num).toPrecision(precision));
}
/**
* Return digits length of a number.
*
* @param num The input number
*/
function digitLength(num) {
// Get digit length of e
var eSplit = num.toString().split(/[eE]/);
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
return len > 0 ? len : 0;
}
/**
* Convert the given number to integer, support scientific notation.
* The number will be scale up if it is decimal.
*
* @param num The input number
*/
function float2Fixed(num) {
if (num.toString().indexOf('e') === -1) {
return Number(num.toString().replace('.', ''));
}
var dLen = digitLength(num);
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
}
/**
* Log a warning if the given number is out of bounds.
*
* @param num The input number
*/
function checkBoundary(num) {
if (_boundaryCheckingState) {
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
console.warn(num + " is beyond boundary when transfer to integer, the results may not be accurate");
}
}
}
/**
* Create an operation to support rest params.
*
* @param operation The original operation
*/
function createOperation(operation) {
return function () {
var nums = [];
for (var _i = 0; _i < arguments.length; _i++) {
nums[_i] = arguments[_i];
}
var first = nums[0], others = nums.slice(1);
return others.reduce(function (prev, next) { return operation(prev, next); }, first);
};
}
/**
* Accurate multiplication.
*
* @param nums The numbers to multiply
*/
var times = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
var baseNum = digitLength(num1) + digitLength(num2);
var leftValue = num1Changed * num2Changed;
checkBoundary(leftValue);
return leftValue / Math.pow(10, baseNum);
});
/**
* Accurate addition.
*
* @param nums The numbers to add
*/
var plus = createOperation(function (num1, num2) {
// 取最大的小数位
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
// 把小数都转为整数然后再计算
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
});
/**
* Accurate subtraction.
*
* @param nums The numbers to subtract
*/
var minus = createOperation(function (num1, num2) {
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
});
/**
* Accurate division.
*
* @param nums The numbers to divide
*/
var divide = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
checkBoundary(num1Changed);
checkBoundary(num2Changed);
// fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
});
/**
* Accurate rounding method.
*
* @param num The number to round
* @param decimal An integer specifying the decimal digits
*/
function round(num, decimal) {
var base = Math.pow(10, decimal);
var result = divide(Math.round(Math.abs(times(num, base))), base);
if (num < 0 && result !== 0) {
result = times(result, -1);
}
return result;
}
var _boundaryCheckingState = true;
/**
* Whether to check the bounds of number, default is enabled.
*
* @param flag The value to indicate whether is enabled
*/
function enableBoundaryChecking(flag) {
if (flag === void 0) { flag = true; }
_boundaryCheckingState = flag;
}
var index = {
strip: strip,
plus: plus,
minus: minus,
times: times,
divide: divide,
round: round,
digitLength: digitLength,
float2Fixed: float2Fixed,
enableBoundaryChecking: enableBoundaryChecking,
};
exports.strip = strip;
exports.plus = plus;
exports.minus = minus;
exports.times = times;
exports.divide = divide;
exports.round = round;
exports.digitLength = digitLength;
exports.float2Fixed = float2Fixed;
exports.enableBoundaryChecking = enableBoundaryChecking;
exports['default'] = index;
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH;;;;;;;GAOG;AACH,SAAS,KAAK,CAAC,GAAe,EAAE,SAAc;IAAd,0BAAA,EAAA,cAAc;IAC5C,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACzD,CAAC;AAuIQ,sBAAK;AArId;;;;GAIG;AACH,SAAS,WAAW,CAAC,GAAe;IAClC,wBAAwB;IACxB,IAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvE,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AA2HkD,kCAAW;AAzH9D;;;;;GAKG;AACH,SAAS,WAAW,CAAC,GAAe;IAClC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QACtC,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;KAChD;IACD,IAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1E,CAAC;AA6G+D,kCAAW;AA3G3E;;;;GAIG;AACH,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,sBAAsB,EAAE;QAC1B,IAAI,GAAG,GAAG,MAAM,CAAC,gBAAgB,IAAI,GAAG,GAAG,MAAM,CAAC,gBAAgB,EAAE;YAClE,OAAO,CAAC,IAAI,CAAI,GAAG,kFAA+E,CAAC,CAAC;SACrG;KACF;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,SAAqD;IAC5E,OAAO;QAAC,cAAqB;aAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;YAArB,yBAAqB;;QACpB,IAAA,KAAK,GAAe,IAAI,GAAnB,EAAK,MAAM,GAAI,IAAI,SAAR,CAAS;QAChC,OAAO,MAAM,CAAC,MAAM,CAAC,UAAC,IAAI,EAAE,IAAI,IAAK,OAAA,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EAArB,CAAqB,EAAE,KAAK,CAAW,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,IAAM,KAAK,GAAG,eAAe,CAAC,UAAC,IAAI,EAAE,IAAI;IACvC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtD,IAAM,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;IAE5C,aAAa,CAAC,SAAS,CAAC,CAAC;IAEzB,OAAO,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAoE0B,sBAAK;AAlElC;;;;GAIG;AACH,IAAM,IAAI,GAAG,eAAe,CAAC,UAAC,IAAI,EAAE,IAAI;IACtC,UAAU;IACV,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7E,gBAAgB;IAChB,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;AACjE,CAAC,CAAC,CAAC;AAwDa,oBAAI;AAtDpB;;;;GAIG;AACH,IAAM,KAAK,GAAG,eAAe,CAAC,UAAC,IAAI,EAAE,IAAI;IACvC,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7E,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC;AACjE,CAAC,CAAC,CAAC;AA8CmB,sBAAK;AA5C3B;;;;GAIG;AACH,IAAM,MAAM,GAAG,eAAe,CAAC,UAAC,IAAI,EAAE,IAAI;IACxC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACtC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAEtC,aAAa,CAAC,WAAW,CAAC,CAAC;IAC3B,aAAa,CAAC,WAAW,CAAC,CAAC;IAE3B,qDAAqD;IACrD,OAAO,KAAK,CAAC,WAAW,GAAG,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC;AA8BiC,wBAAM;AA5B1C;;;;;GAKG;AACH,SAAS,KAAK,CAAC,GAAe,EAAE,OAAe;IAC7C,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACnC,IAAI,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAElE,IAAI,GAAG,GAAG,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE;QAC3B,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;KAC5B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAa2C,sBAAK;AAXjD,IAAI,sBAAsB,GAAG,IAAI,CAAC;AAElC;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,IAAW;IAAX,qBAAA,EAAA,WAAW;IACzC,sBAAsB,GAAG,IAAI,CAAC;AAChC,CAAC;AAE4E,wDAAsB;AAEnG,kBAAe;IACb,KAAK,OAAA;IACL,IAAI,MAAA;IACJ,KAAK,OAAA;IACL,KAAK,OAAA;IACL,MAAM,QAAA;IACN,KAAK,OAAA;IACL,WAAW,aAAA;IACX,WAAW,aAAA;IACX,sBAAsB,wBAAA;CACvB,CAAC"}
\ No newline at end of file \ No newline at end of file
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.NP = {})));
}(this, (function (exports) { 'use strict';
/**
* @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
*
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
*/
/**
* Correct the given number to specifying significant digits.
*
* @param num The input number
* @param precision An integer specifying the number of significant digits
*
* @example strip(0.09999999999999998) === 0.1 // true
*/
function strip(num, precision) {
if (precision === void 0) { precision = 15; }
return +parseFloat(Number(num).toPrecision(precision));
}
/**
* Return digits length of a number.
*
* @param num The input number
*/
function digitLength(num) {
// Get digit length of e
var eSplit = num.toString().split(/[eE]/);
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
return len > 0 ? len : 0;
}
/**
* Convert the given number to integer, support scientific notation.
* The number will be scale up if it is decimal.
*
* @param num The input number
*/
function float2Fixed(num) {
if (num.toString().indexOf('e') === -1) {
return Number(num.toString().replace('.', ''));
}
var dLen = digitLength(num);
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
}
/**
* Log a warning if the given number is out of bounds.
*
* @param num The input number
*/
function checkBoundary(num) {
if (_boundaryCheckingState) {
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
console.warn(num + " is beyond boundary when transfer to integer, the results may not be accurate");
}
}
}
/**
* Create an operation to support rest params.
*
* @param operation The original operation
*/
function createOperation(operation) {
return function () {
var nums = [];
for (var _i = 0; _i < arguments.length; _i++) {
nums[_i] = arguments[_i];
}
var first = nums[0], others = nums.slice(1);
return others.reduce(function (prev, next) { return operation(prev, next); }, first);
};
}
/**
* Accurate multiplication.
*
* @param nums The numbers to multiply
*/
var times = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
var baseNum = digitLength(num1) + digitLength(num2);
var leftValue = num1Changed * num2Changed;
checkBoundary(leftValue);
return leftValue / Math.pow(10, baseNum);
});
/**
* Accurate addition.
*
* @param nums The numbers to add
*/
var plus = createOperation(function (num1, num2) {
// 取最大的小数位
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
// 把小数都转为整数然后再计算
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
});
/**
* Accurate subtraction.
*
* @param nums The numbers to subtract
*/
var minus = createOperation(function (num1, num2) {
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
});
/**
* Accurate division.
*
* @param nums The numbers to divide
*/
var divide = createOperation(function (num1, num2) {
var num1Changed = float2Fixed(num1);
var num2Changed = float2Fixed(num2);
checkBoundary(num1Changed);
checkBoundary(num2Changed);
// fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
});
/**
* Accurate rounding method.
*
* @param num The number to round
* @param decimal An integer specifying the decimal digits
*/
function round(num, decimal) {
var base = Math.pow(10, decimal);
var result = divide(Math.round(Math.abs(times(num, base))), base);
if (num < 0 && result !== 0) {
result = times(result, -1);
}
return result;
}
var _boundaryCheckingState = true;
/**
* Whether to check the bounds of number, default is enabled.
*
* @param flag The value to indicate whether is enabled
*/
function enableBoundaryChecking(flag) {
if (flag === void 0) { flag = true; }
_boundaryCheckingState = flag;
}
var index = {
strip: strip,
plus: plus,
minus: minus,
times: times,
divide: divide,
round: round,
digitLength: digitLength,
float2Fixed: float2Fixed,
enableBoundaryChecking: enableBoundaryChecking,
};
exports.strip = strip;
exports.plus = plus;
exports.minus = minus;
exports.times = times;
exports.divide = divide;
exports.round = round;
exports.digitLength = digitLength;
exports.float2Fixed = float2Fixed;
exports.enableBoundaryChecking = enableBoundaryChecking;
exports['default'] = index;
Object.defineProperty(exports, '__esModule', { value: true });
})));
{
"_from": "number-precision",
"_id": "number-precision@1.6.0",
"_inBundle": false,
"_integrity": "sha512-05OLPgbgmnixJw+VvEh18yNPUo3iyp4BEWJcrLu4X9W05KmMifN7Mu5exYvQXqxxeNWhvIF+j3Rij+HmddM/hQ==",
"_location": "/number-precision",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "number-precision",
"name": "number-precision",
"escapedName": "number-precision",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/number-precision/-/number-precision-1.6.0.tgz",
"_shasum": "e309d28f80871d36ac9f6ecd974e13afb1ec0de0",
"_spec": "number-precision",
"_where": "D:\\2023\\07\\海马刀",
"author": {
"name": "cam song"
},
"ava": {
"files": [
"build-test/**/*.test.js"
]
},
"bugs": {
"url": "https://github.com/nefe/number-precision/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Perform addition, subtraction, multiplication and division operations precisely using javascript",
"devDependencies": {
"ava": "^3.8.2",
"braces": ">=2.3.1",
"codecov": "^3.1.0",
"nyc": "^15.0.1",
"pre-commit": "^1.2.2",
"rollup": "^0.52.2",
"rollup-plugin-typescript": "^0.8.1",
"rollup-plugin-typescript2": "^0.8.4",
"rollup-watch": "^4.3.1",
"tslint": "^5.8.0",
"typescript": "^3.8.3"
},
"homepage": "https://github.com/nefe/number-precision",
"keywords": [
"number precision",
"floating problem",
"rounding error"
],
"license": "MIT",
"main": "build/index.js",
"module": "build/index.es.js",
"name": "number-precision",
"pre-commit": [
"tslint"
],
"repository": {
"type": "git",
"url": "git+https://github.com/nefe/number-precision.git"
},
"scripts": {
"build": "rollup -c",
"posttest": "codecov -f coverage/*.json -t 072762c4-c5bc-4393-bcd9-71eac9e7725b",
"prepublish": "rm -rf build && tsc && npm run build",
"test": "tsc -p tsconfig.test.json && nyc --reporter=lcov --reporter=text --reporter=json ava && rm -rf .nyc_output",
"tslint": "tslint ./src/**/*.ts --fix",
"watch": "rollup -cw"
},
"types": "build/index.d.ts",
"version": "1.6.0"
}
import typescript from 'rollup-plugin-typescript2'
export default {
input: './src/index.ts',
output: [
{
format: 'iife',
name: 'NP',
dest: './build/index.iife.js'
},
{
format: 'umd',
name: 'NP',
dest: './build/index.umd.js'
},
{
format: 'cjs',
dest: './build/index.js'
},
{
format: 'es',
dest: './build/index.es.js'
}
],
plugins: [typescript({cacheRoot: `${require('temp-dir')}/.rpt2_cache`})]
}
/**
* @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
*
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
*/
type NumberType = number | string;
/**
* Correct the given number to specifying significant digits.
*
* @param num The input number
* @param precision An integer specifying the number of significant digits
*
* @example strip(0.09999999999999998) === 0.1 // true
*/
function strip(num: NumberType, precision = 15): number {
return +parseFloat(Number(num).toPrecision(precision));
}
/**
* Return digits length of a number.
*
* @param num The input number
*/
function digitLength(num: NumberType): number {
// Get digit length of e
const eSplit = num.toString().split(/[eE]/);
const len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
return len > 0 ? len : 0;
}
/**
* Convert the given number to integer, support scientific notation.
* The number will be scale up if it is decimal.
*
* @param num The input number
*/
function float2Fixed(num: NumberType): number {
if (num.toString().indexOf('e') === -1) {
return Number(num.toString().replace('.', ''));
}
const dLen = digitLength(num);
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
}
/**
* Log a warning if the given number is out of bounds.
*
* @param num The input number
*/
function checkBoundary(num: number) {
if (_boundaryCheckingState) {
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
console.warn(`${num} is beyond boundary when transfer to integer, the results may not be accurate`);
}
}
}
/**
* Create an operation to support rest params.
*
* @param operation The original operation
*/
function createOperation(operation: (n1: NumberType, n2: NumberType) => number): (...nums: NumberType[]) => number {
return (...nums: NumberType[]) => {
const [first, ...others] = nums;
return others.reduce((prev, next) => operation(prev, next), first) as number;
};
}
/**
* Accurate multiplication.
*
* @param nums The numbers to multiply
*/
const times = createOperation((num1, num2) => {
const num1Changed = float2Fixed(num1);
const num2Changed = float2Fixed(num2);
const baseNum = digitLength(num1) + digitLength(num2);
const leftValue = num1Changed * num2Changed;
checkBoundary(leftValue);
return leftValue / Math.pow(10, baseNum);
});
/**
* Accurate addition.
*
* @param nums The numbers to add
*/
const plus = createOperation((num1, num2) => {
// 取最大的小数位
const baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
// 把小数都转为整数然后再计算
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
});
/**
* Accurate subtraction.
*
* @param nums The numbers to subtract
*/
const minus = createOperation((num1, num2) => {
const baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
});
/**
* Accurate division.
*
* @param nums The numbers to divide
*/
const divide = createOperation((num1, num2) => {
const num1Changed = float2Fixed(num1);
const num2Changed = float2Fixed(num2);
checkBoundary(num1Changed);
checkBoundary(num2Changed);
// fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
});
/**
* Accurate rounding method.
*
* @param num The number to round
* @param decimal An integer specifying the decimal digits
*/
function round(num: NumberType, decimal: number): number {
const base = Math.pow(10, decimal);
let result = divide(Math.round(Math.abs(times(num, base))), base);
if (num < 0 && result !== 0) {
result = times(result, -1);
}
return result;
}
let _boundaryCheckingState = true;
/**
* Whether to check the bounds of number, default is enabled.
*
* @param flag The value to indicate whether is enabled
*/
function enableBoundaryChecking(flag = true) {
_boundaryCheckingState = flag;
}
export { strip, plus, minus, times, divide, round, digitLength, float2Fixed, enableBoundaryChecking };
export default {
strip,
plus,
minus,
times,
divide,
round,
digitLength,
float2Fixed,
enableBoundaryChecking,
};
{
"compilerOptions": {
"module": "commonjs",
"strict": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es5",
"es6"
],
"target": "es5",
"outDir": "build",
"sourceMap": true,
"declaration": true
},
"include": [
"src/*.ts"
],
"exclude": [
"node_modules"
]
}
{
"compilerOptions": {
"module": "commonjs",
"strict": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es5",
"es6"
],
"target": "es5",
"outDir": "build-test",
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
{
"extends": ["tslint:recommended"],
"rules": {
"arrow-parens": false,
"arrow-return-shorthand": [true],
"import-spacing": true,
"interface-name": [false],
"interface-over-type-literal": false,
"linebreak-style": [true, "LF"],
"max-classes-per-file": [false],
"member-access": [false],
"no-require-imports": true,
"object-literal-sort-keys": false,
"ordered-imports": [false],
"no-console": false,
"prefer-const": true,
"quotemark": [true, "single", "jsx-double"],
"space-before-function-paren": [true, {
"anonymous": "always",
"asyncArrow": "always",
"constructor": "never",
"method": "never",
"named": "never"
}],
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-pascal-case",
"allow-leading-underscore"
]
}
}
{ {
"requires": true, "name": "hmd",
"version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true,
"dependencies": { "dependencies": {
"glsx-map-sdk": { "glsx-map-sdk": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/glsx-map-sdk/-/glsx-map-sdk-0.2.0.tgz", "resolved": "https://registry.npmjs.org/glsx-map-sdk/-/glsx-map-sdk-0.2.0.tgz",
"integrity": "sha512-uEFlXvJEDofYjasR4mwkmF5yNTRs5QA2ZAynGPHiKpKdpjQkVFPJH0zGupmQEkxmh4f5B0wPbDobHvLgld7mVw==" "integrity": "sha512-uEFlXvJEDofYjasR4mwkmF5yNTRs5QA2ZAynGPHiKpKdpjQkVFPJH0zGupmQEkxmh4f5B0wPbDobHvLgld7mVw=="
},
"number-precision": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/number-precision/-/number-precision-1.6.0.tgz",
"integrity": "sha512-05OLPgbgmnixJw+VvEh18yNPUo3iyp4BEWJcrLu4X9W05KmMifN7Mu5exYvQXqxxeNWhvIF+j3Rij+HmddM/hQ=="
} }
} }
} }
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
"version": "1.0.0", "version": "1.0.0",
"main": "app.js", "main": "app.js",
"dependencies": { "dependencies": {
"glsx-map-sdk": "^0.2.0" "glsx-map-sdk": "^0.2.0",
"number-precision": "^1.6.0"
}, },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
......
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function (n) {
if (n) setTimeout(() => {}, 0.5 * 1000)
}
},
only: {
type: Boolean,
value: true
},
couponData: {
type: Object,
observer(n) {
if (n.length)
this.setData({
noData: true
})
return n
}
},
order: {
type: Number
},
defaultData: String
},
observers: {
couponData: function (newVal) {
return newVal
}
},
/**
* 组件的初始数据
*/
data: {
noData: false,
IMGURL: wx.$imgUrl
},
/**
* 组件的方法列表
*/
methods: {
getCoupon(e) {
let {merchantId} = wx.p.storage.get('merchant_info')
let { item } = e.currentTarget.dataset
wx.p.wxApi.showLoading('领取中...')
wx.p.api.shopmallApi
.getCoupon({
couponIdList: [item.couponId],
receiveWay: 1,
receiveSource: 3,
merchantId: Number(merchantId)
})
.then(({ code, data, message }) => {
console.log(data)
wx.hideLoading()
if (code == '0') {
wx.showToast({
title: '领取成功',
icon: 'none'
})
let thisPage = wx.p.router.getPageInstance()
if (thisPage.getGoodscouponList) thisPage.getGoodscouponList()
}
})
},
// 更换优惠券
selectCoupon(e) {
let { index } = e.currentTarget.dataset
for (let i = 0; i < this.data.couponData.length; i++) {
if (index == i) {
this.data.couponData[i].isChecked = !this.data.couponData[i].isChecked
} else {
this.data.couponData[i].isChecked = false
}
this.setData({
couponData: this.data.couponData
})
}
},
//确认
confirm() {
this.triggerEvent('click', this.data.couponData)
this.setData({
couponData: this.data.couponData
})
}
},
lifetimes: {
attached() {}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<popup title="优惠详情" show="{{show}}" only="{{only}}" bindconfirm="confirm" height="75%">
<view class="coupon-box">
<view class="box">
<scroll-view style="height:100%;" scroll-y>
<block wx:if="{{noData}}">
<view class="coupon-wrap" wx:for="{{couponData}}" wx:key="index">
<view class="left_icon_box">
<image webp wx:if="{{true}}" class="left_bg" src="{{IMGURL}}coupons/coupons_active.png?v={{img_version}}" />
<image webp wx:else class="left_bg" src="{{IMGURL}}coupons/coupons.png?v={{img_version}}" />
<view class="left_text_one left_text_two">
<text class="price_icon">¥</text>
<text>{{(item.denomination)/100}}</text>
</view>
<view class="left_text_five left_text_three" wx:if="{{item.full}}">满{{(item.full)/100}}可用</view>
</view>
<view class="main_box">
<view class="title_text">{{item.couponName}}</view>
<view class="h4_text" wx:if="{{item.useBarriers == 1}}">无限制</view>
<view class="h4_text" wx:if="{{item.useBarriers == 2}}">满减</view>
<!-- 未领取,effectiveType == 1,就显示effectiveDays有效,effectiveType == 2 显示时间段,effectiveType == 3 无限制 -->
<view class="h4_text drive" wx:if="{{item.couponStatus == 0&&item.effectiveType == 1}}">领取后{{item.effectiveDays}}天内有效</view>
<view class="h4_text drive" wx:if="{{item.couponStatus == 0&&item.effectiveType == 2}}">{{item.effectiveStartTime}}-{{item.effectiveEndTime}}</view>
<view class="h4_text drive" wx:if="{{item.couponStatus == 0&&item.effectiveType == 3}}">无期限</view>
<!-- 已领取,effectiveType == 1 或者2,都显示时间段,effectiveType == 3 无限制 -->
<view class="h4_text drive" wx:if="{{item.couponStatus == 1&&item.effectiveType == 1||item.couponStatus == 1&&item.effectiveType == 2 }}">{{item.effectiveStartTime}}-{{item.effectiveEndTime}}</view>
<view class="h4_text drive" wx:if="{{item.couponStatus == 1&&item.effectiveType == 3}}">无期限</view>
</view>
<block wx:if="{{order == 0}}">
<view class="box_btn box_btn_color" bindtap="toDetail" wx:if="{{item.couponStatus == 0&&item.residueAmount >0}}" data-item="{{item}}" bindtap="getCoupon">领取</view>
<view class="box_btn_color_been_gray " bind:tap="toDetail" wx:elif="{{item.couponStatus != 1&&item.residueAmount ==0}}">已抢光</view>
<view class="box_btn_color_been" bind:tap="toDetail" wx:elif="{{item.couponStatus == 1}}">已领取</view>
<view class="already" wx:if="{{item.couponStatus == 1}}">
<image webp src="{{IMGURL}}coupons/been.png?v={{img_version}}" />
</view>
</block>
<block wx:else>
<view class="circle-selected" data-item="{{item}}" data-index="{{index}}" wx:if="{{item.isChecked}}" bindtap="selectCoupon">
<image webp src="{{IMGURL}}coupons/select.png?v={{img_version}}" />
</view>
<view class="noSelect" data-item="{{item}}" data-index="{{index}}" wx:if="{{!item.isChecked}}" bindtap="selectCoupon"></view>
</block>
</view>
</block>
<!-- <block>
<view class="dissatisfy">以下不满足使用条件</view>
<view class="coupon-wrap gray" >
<view class="left_icon_box">
<image webp class="left_bg" src="../../packageMall/images/coupons.png" />
<view class="left_text_one left_text_two">
<text class="price_icon">¥</text>
<text>50</text>
</view>
<view class="left_text_five left_text_three">满99可用</view>
</view>
<view class="main_box">
<view class="title_text">优惠券名称</view>
<view class="h4_text">满300减50,仅限会场商品</view>
<view class="h4_text drive">无限期</view>
</view>
<view class="circle-gray"></view>
<view class="reason">不可用原因:仅可购买XXX商品A</view>
</view>
</block> -->
</scroll-view>
</view>
</view>
<view wx:if="{{!noData}}" class="no_data">
<image webp class="nodata_bg" src="{{IMGURL}}coupons/no_card_bg.png?v={{img_version}}" />
<view class="nodata_text">暂无优惠券</view>
</view>
</popup>
\ No newline at end of file \ No newline at end of file
/* components/CarBrands/CarBrands.wxss */
.coupon-wrap {
width: 686rpx;
height: 196rpx;
background: rgba(252, 91, 50, 0.05);
border-radius: 8rpx;
box-sizing: border-box;
padding: 20rpx;
display: flex;
align-items: center;
position: relative;
margin-top: 24rpx;
}
.gray {
width: 686rpx;
height: 196rpx;
background: rgba(201, 202, 204, 0.1) !important;
border-radius: 8rpx;
box-sizing: border-box;
padding: 20rpx;
display: flex;
align-items: center;
position: relative;
margin-top: 24rpx;
}
.left_icon_box {
width: 156rpx;
height: 156rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.left_bg {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 156rpx;
height: 156rpx;
z-index: 1;
}
.left_text_one {
font-size: 36rpx;
font-weight: 600;
color: #FFFFFF;
z-index: 2;
}
.left_text_two {
display: flex;
align-items: flex-end;
}
.left_text_four {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.left_text_three {
font-size: 28rpx;
margin-top: 6rpx;
width:156rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text-align: center;
}
.left_text_five {
font-size: 28rpx;
color: #FFFFFF;
z-index: 2;
}
.anText {
font-size: 70rpx;
/* color: rgba(white, white, white, 0.45); */
font-weight: 600;
color: #FFF;
opacity: 0.45;
}
.price_icon {
font-size: 20rpx;
margin-right: 4rpx;
margin-bottom: 7rpx;
}
.main_box {
height: 156rpx;
box-sizing: border-box;
padding: 4rpx 0 4rpx 20rpx;
}
.box_btn {
position: absolute;
right: 20rpx;
top: 50%;
transform: translate(0, -50%);
width: 132rpx;
height: 50rpx;
background: #B1B1B3;
border-radius: 22rpx;
color: #FFF;
font-size: 20rpx;
text-align: center;
line-height: 50rpx;
}
.box_btn_color {
background: var(--btnColor);
color: #FFFFFF;
}
.box_btn_color_grey {
background: #B1B1B3;
}
.title_text {
color: #282829;
font-weight: 600;
color: #282829;
font-size: 28rpx;
width: 420rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.box_btn_color_been {
font-size: 28rpx;
font-weight: 400;
color: var(--btnColor);
line-height: 40rpx;
white-space: nowrap;
position: absolute;
right: 20rpx;
top: 50%;
transform: translate(0, -50%);
}
.h4_text {
font-weight: 400;
color: #B1B1B3;
font-size: 24rpx;
}
.drive {
margin-top: 38rpx;
}
.y-center {
display: flex;
align-items: center;
}
.no_data {
padding-top: 48rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.nodata_bg {
width: 320rpx;
height: 320rpx;
}
.nodata_text {
color: #B1B1B3;
font-size: 28rpx;
line-height: 44rpx;
margin-top: 8rpx;
}
.already {
width: 75rpx;
height: 74rpx;
position: absolute;
bottom: 0;
right: 0;
z-index: 99;
}
.dissatisfy {
font-size: 28rpx;
font-weight: 500;
color: #282829;
line-height: 44rpx;
margin-top: 32rpx;
}
.circle-gray {
width: 40rpx;
height: 40rpx;
background: #E3E3E6;
border: 2rpx solid rgba(177, 177, 179, 1);
border-radius: 50%;
}
.reason {
width: 686rpx;
height: 60rpx;
background: rgba(253, 194, 62, 0.06);
font-size: 24rpx;
font-weight: 400;
color: #F13C3D;
line-height: 60rpx;
padding: 0 20rpx;
box-sizing: border-box;
position: absolute;
bottom: -60rpx;
left: 0;
}
.reason::before {
content: '!';
width: 28rpx;
height: 28rpx;
border: 1rpx solid #F13C3D;
color: #F13C3D;
box-sizing: border-box;
border-radius: 50%;
display: inline-block;
text-align: center;
line-height: 24rpx;
margin-right: 12rpx;
}
.circle-selected {
width: 40rpx;
height: 40rpx;
}
.noSelect {
width: 40rpx;
height: 40rpx;
background: #ffffff;
border: 2rpx solid rgba(177, 177, 179, 1);
border-radius: 50%;
}
.box{
height:55vh;
overflow-y: scroll;
padding-bottom: 50rpx;
}
.box_btn_color_been_gray{
font-size: 28rpx;
font-weight: 400;
color: #B1B1B3;
line-height: 40rpx;
white-space: nowrap;
position: absolute;
right: 20rpx;
top: 50%;
transform: translate(0, -50%);
}
\ No newline at end of file \ No newline at end of file
// components/Sku/Sku.js
import { centsToyuan } from '~/utils/format'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer(n) {
if (n)
this.setData({
close: false
})
}
},
showName: String,
skuData: {
type: Object,
observer(n) {
this.setDefaultSku(n)
}
},
isActivity: Boolean
},
/**
* 组件的初始数据
*/
data: {
goodsNumber: 1
},
/**
* 组件的方法列表
*/
methods: {
noScroll() {},
setDefaultSku(skuData) {
let { isActivity } = this.data
let { specificationList } = skuData
let [specificationDetailList] = isActivity ? skuData.specificationExtraList : skuData.specificationDetailList
let defaultGoods = specificationDetailList.specificationData.split('&')
specificationList.map(e => {
defaultGoods.map(i => {
let [key, value] = i.split('-')
if (key == e.specificationName) {
e.specificationValueList.map(c => {
if (c.specificationValue == value) c.active = true
})
}
})
})
specificationDetailList.retailPrice = centsToyuan(specificationDetailList.retailPrice)
this.setData({
skuObj: skuData,
goodsInfo: specificationDetailList
})
},
choose(e) {
let { ind, index } = e.currentTarget.dataset
let {
skuObj: { specificationList, id, specificationExtraList },
isActivity
} = this.data
let activeList = []
if (specificationList[index].specificationValueList[ind].active) return
specificationList[index].specificationValueList.map(i => (i.active = false))
specificationList[index].specificationValueList[ind].active = true
specificationList.map(i => {
i.specificationValueList.map(c => {
if (c.active) activeList.push(`${i.specificationName}-${c.specificationValue}`)
})
})
let specificationData = activeList.join('&')
this.setData({
[`skuObj.specificationList[${index}]`]: specificationList[index]
})
if (isActivity) {
specificationExtraList.map((i, i_index) => {
if (i.specificationData == specificationData) {
let retailPrice = i.retailPrice
if (i_index != 0) retailPrice = centsToyuan(i.retailPrice)
this.setData({
goodsInfo: {
retailPrice,
stock: i.stock,
specificationData,
specificationKey: i.specificationKey
}
})
}
})
} else {
wx.p.api.shopmallApi
.getGoodsSpecificationExtra({
goodsId: id,
specificationData
})
.then(data => {
data.retailPrice = centsToyuan(data.retailPrice)
this.setData({
goodsInfo: data
})
console.log(this.data.goodsInfo)
})
}
this.setData({
goodsNumber: 1
})
const thisPage = wx.p.router.getPageInstance()
thisPage.setData({
activeSku: specificationData
})
},
changeCount(e) {
let goodsNumber = e.detail
this.setData({
goodsNumber
})
},
closeSku() {
let thisPage = wx.p.router.getPageInstance()
let { showName } = this.data
this.setData({
close: true
})
setTimeout(() => {
thisPage.setData({
[showName]: false
})
}, 0.5 * 1000)
},
click(e) {
let { type } = e.currentTarget.dataset
let {
goodsInfo: { goodsId, specificationKey, stock },
goodsNumber
} = this.data
if (stock === 0) return
this.triggerEvent(type, {
goodsId,
specificationKey,
goodsNumber,
stock
})
this.closeSku()
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="sku" catchtouchmove="noScroll" hidden="{{!show}}">
<view class="sku-bg" bindtap="closeSku"></view>
<view class="sku-box isFullSucreen {{close?'close':''}}">
<scroll-view class="sku-content" scroll-y>
<view class="view">
<view class="goods-box">
<view class="preview">
<image webp src="{{skuObj.goodsImage || skuObj.activityImg}}"></image>
</view>
<view class="goods-info">
<view class="price">
<text class="unit">¥</text>{{goodsInfo.retailPrice}}
</view>
<view class="count">
<block wx:if="{{goodsInfo.stock}}">
有货(库存{{goodsInfo.stock}})
</block>
<block wx:else>无货</block>
</view>
<view class="active text-hide">已选:{{goodsInfo.specificationData}}</view>
</view>
</view>
<view class="sku-list">
<block wx:for="{{skuObj.specificationList}}" wx:key="index">
<view class="sku-title">{{item.specificationName}}</view>
<view class="sku-item">
<block wx:for="{{item.specificationValueList}}" wx:key="ind" wx:for-index="ind" wx:for-item="i">
<view class="item text-center {{i.active?'active':''}} {{i.stock ===0?'disabled':''}}" bindtap="choose" data-index="{{index}}"
data-ind="{{ind}}">{{i.specificationValue}}</view>
</block>
</view>
</block>
<view class="sku-title">
数量
<stepper count="{{goodsNumber}}" max="{{goodsInfo.stock}}" bindchange="changeCount"></stepper>
</view>
<view class="sku-title">
发货
<view class="value">快递:{{skuObj.expressFee||'免运费(请以提交订单时为准)'}}</view>
</view>
</view>
</view>
</scroll-view>
<view class="sku-btn-box">
<view class="sku-btn">
<block wx:if="{{!isActivity}}">
<view class="join text-center {{goodsInfo.stock === 0?'disabled':''}}" bindtap="click" data-type="join">加入购物车</view>
</block>
<view class="pay text-center {{goodsInfo.stock === 0?'disabled':''}} " bindtap="click" data-type="pay">立即购买</view>
</view>
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
/* components/Sku/Sku.wxss */
@import '/style/common.wxss';
.sku {
position: fixed;
left: 0;
bottom: 0;
right: 0;
top: 0;
z-index: 9;
}
.sku-bg {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
}
.sku-box {
position: absolute;
width: 100%;
height: 76%;
background: #FFFFFF;
border-radius: 16rpx 16rpx 0 0;
left: 0;
animation: show-sku-box .5s forwards;
z-index: 2;
}
.sku-box.close {
animation: hide-popup-box .5s forwards;
}
.sku-box.isFullSucreen {
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
@keyframes show-sku-box {
0% {
bottom: -100%;
}
100% {
bottom: 0;
}
}
@keyframes hide-popup-box {
0% {
bottom: 0;
}
100% {
bottom: -100%;
}
}
.sku-content {
box-sizing: border-box;
height: calc(100% - 100rpx);
}
.sku-content .view {
padding: 0 40rpx;
}
.sku-content .goods-box {
display: flex;
align-items: center;
position: sticky;
background-color: #fff;
z-index: 2;
top: 0;
padding-bottom: 18rpx;
}
.sku-content .goods-box .preview {
width: 180rpx;
height: 180rpx;
border-radius: 4rpx;
margin-right: 40rpx;
overflow: hidden;
margin-top: 40rpx;
}
.sku-content .goods-box .goods-info {
width: calc(100% - 220rpx);
}
.sku-content .goods-box .price {
color: var(--btnColor);
font-size: 64rpx;
margin-bottom: 10rpx;
}
.sku-content .goods-box .price .unit {
font-size: 40rpx;
}
.sku-content .goods-box .count {
color: #B9BABB;
font-size: 20rpx;
margin-bottom: var(--borderRadius);
}
.sku-content .goods-box .active {
font-size: 20rpx;
color: #707071;
}
.sku-box .sku-list {
padding-bottom: 40rpx;
}
.sku-box .sku-title {
color: #2D2D2E;
font-weight: 500;
padding-top: var(--margin);
display: flex;
align-items: center;
justify-content: space-between;
}
.sku-title .value {
color: #565759;
font-weight: normal;
}
.sku-box .sku-item {
display: flex;
flex-wrap: wrap;
}
.sku-box .sku-item .item {
height: 52rpx;
background: #F7F8FA;
padding: 0 20rpx;
margin: 20rpx 20rpx 0 0;
font-size: 24rpx;
color: #656566;
border: 2rpx solid #F7F8FA;
box-sizing: border-box;
border-radius: 4rpx;
}
.sku-box .sku-item .item.active {
border-color: rgb(252, 91, 50);
color: rgb(252, 91, 50);
background-color: rgba(252, 91, 50, .06);
}
.sku-btn-box {
height: 100rpx;
padding: 10rpx var(--margin);
}
.sku-btn {
border-radius: var(--borderRadius);
display: flex;
overflow: hidden;
}
.sku-btn .join,
.sku-btn .pay {
flex: 1;
height: 80rpx;
color: #fff;
}
.sku-btn .join {
background-color: #FDC23E;
}
.sku-btn .pay {
background-color: var(--btnColor);
}
.disabled{
background-color: #B1B1B3 !important;
/* border-color: #B1B1B3 !important; */
color: #000000!important;
}
\ No newline at end of file \ No newline at end of file
// packageMall/pages/detail/detail.js
import {
commentTime,
centsToyuan,
iosTimeFormat
} from '~/utils/format'
const navStyle = 'background-color: transparent;'
let navBarHeight = 38
import NP from 'number-precision'
Page({
/**
* 页面的初始数据
*/
data: {
navStyle,
bannerIndex: 0,
contactInfo: {},
couponData: [],
only: false,
isLoading: true
},
save() {
let {
posterUrl
} = this.data
wx.getImageInfo({
src: posterUrl
})
.then(res => {
wx.saveImageToPhotosAlbum({
filePath: res.path,
success() {
wx.p.wxApi.showToast('保存成功')
},
fail(err) {
if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
wx.showModal({
title: '提示',
content: '需要您授权保存相册',
showCancel: false,
success() {
wx.openSetting({
success(settingdata) {
if (settingdata.authSetting['scope.writePhotosAlbum']) {
wx.showModal({
title: '提示',
content: '获取权限成功,再次保存图片即可成功',
showCancel: false
})
} else {
wx.showModal({
title: '提示',
content: '获取权限失败,无法保存到相册',
showCancel: false
})
}
}
})
}
})
}
}
})
})
.catch(() => {
wx.hideLoading()
wx.p.wxApi.showToast('图片保存失败,请重试')
})
},
previewImage(e) {
let {
current,
item
} = e.currentTarget.dataset
let urls = []
item.map(i => {
if (i.resType == 1) urls.push(i.content)
})
wx.p.wxApi.previewImage({
current,
urls
})
},
previewCommentImage(e) {
let {
current,
item
} = e.currentTarget.dataset
let urls = []
item.map(i => {
urls.push(i)
})
wx.p.wxApi.previewImage({
current,
urls
})
},
jump(e) {
let {
url,
isChooseAddress
} = e.currentTarget.dataset
wx.p.router.go(url, {
isChooseAddress
})
},
navbarReady(e) {
navBarHeight = e.detail.height
},
onPageScroll(e) {
this.setData({
navStyle: e.scrollTop >= navBarHeight ? '' : navStyle
})
},
goodsActionReady(e) {
this.setData({
padding_bottom: e.detail
})
},
showSkuFun() {
this.setData({
showSku: true
})
},
showCouponFun() {
this.setData({
showCoupon: !this.data.showCoupon
})
},
goodsActionClick(e) {
let type = e.detail
let {
activeSku,
isActivity,
goodsInfo: {
activityStatus,
goodsStock,
buyFlag
}
} = this.data
if (activeSku) {
this.showSkuFun()
return
}
if (isActivity && activityStatus != 2) return
if (goodsStock == 0) return
if (buyFlag == 2) return
if (type == 'pay') {
this.pay()
} else {
this.join()
}
},
pay(e) {
let {
isActivity,
isLive,
contactInfo,
goodsInfo,
activeSku,
isDefault
} = this.data
let stock
if (wx.$authStatus) {
wx.navigateTo({
url: '/pages/Login/Login'
})
return
}
let params = {
orderSource: 1
}
let orderGoodsList = {}
let goodsList = {}
if (e && e.detail) {
orderGoodsList = e.detail
goodsList = e.detail
stock = e.detail.stock
} else {
orderGoodsList = {
goodsNumber: 1,
goodsId: goodsInfo.id
}
goodsList = {
goodsNumber: 1
}
}
if (isLive) {
params.orderSource = 2
params.roomId = ''
}
goodsList = {
...goodsList,
merchantName: goodsInfo.merchantName,
goodsImage: goodsInfo.goodsImage,
goodsName: goodsInfo.goodsName,
retailPrice: goodsInfo.retailPrice,
stock: goodsInfo.goodsStock,
id: goodsInfo.id
}
if (activeSku) {
let list = isActivity ? goodsInfo.specificationExtraList : goodsInfo.specificationDetailList
list.map(e => {
if (e.specificationData == activeSku) {
goodsList.retailPrice = centsToyuan(e.retailPrice)
stock ? (goodsList.stock = stock) : (goodsList.stock = e.stock)
}
})
goodsList.specificationData = activeSku
}
if (isActivity) {
params.orderSource = 3
params.activityId = goodsInfo.id
orderGoodsList.goodsId = goodsInfo.goodsId
orderGoodsList.activityPrice = NP.times(goodsInfo.retailPrice, 100)
// goodsList.goodsImage = goodsInfo.activityImg
// goodsList.goodsName = goodsInfo.activityName
;
(goodsList.goodsId = goodsInfo.goodsId), (goodsList.stock = goodsInfo.goodsStock), (goodsList.id = goodsInfo.id)
}
params.orderGoodsList = [orderGoodsList]
goodsList.expressFee = goodsInfo.expressFee
if (!contactInfo.contactAddress && goodsInfo.deliveryType != 1) {
wx.p.wxApi.showToast('请填写收货地址')
return
}
wx.p.router.go('/packageMall/pages/pay/pay', {
isPay: true,
isActivity,
contactInfo,
goodsList,
isDefault,
params,
goodsInfo
})
},
async join(e) {
wx.p.router.intercept()
let params = e && e.detail
if (!params) {
params = {
goodsId: this.data.goodsInfo.id,
goodsNumber: 1
}
}
wx.p.wxApi.showLoading('请稍后...')
try {
const res = await wx.p.api.shopmallApi.addShoppingcart(params)
if (res) wx.p.wxApi.showToast('添加成功!在购物车等亲~')
} catch (error) {
wx.p.wxApi.showToast('操作失败')
}
},
back() {
wx.p.router.back()
},
changeBanner(e) {
this.setData({
bannerIndex: e.detail.current
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (this.data.id) {
this.getGoodsDetail(this.data.id)
} else {
/**扫码、分享、直播间 */
if (options && options.id) {
this.setData(options)
this.getGoodsDetail(options.id)
if (!options.isActivity) this.getGoodscouponList(options.id)
}
}
// 推荐人+推荐人埋点
if (options.shareStaffUuid) {
let shareStaff = {
shareStaffUuid: options.shareStaffUuid,
shareStaffName: options.shareStaffName
}
options.item_type = options.isActivity ? 3 : 1
options.action_type = 1
options.item_id = options.id
wx.p.util.reportData(options, false, false, true)
wx.p.storage.set('shareStaff', JSON.stringify(shareStaff))
wx.p.storage.set('shareStaffTracker', JSON.stringify(options))
}
// 埋点
if (options.activity_id) {
this.data.options = options
wx.p.storage.set('miaoshatrack', encodeURIComponent(JSON.stringify(options)))
wx.p.util.reportData(options, true, false)
}
},
getGoodsDetail(id) {
let {
isActivity,
} = this.data
let target = isActivity ? 'getActivityDetail' : 'getGoodsDetail'
wx.p.wxApi.showLoading('加载中...')
wx.p.api.shopmallApi[target](id).then(({
code,
data,
message
}) => {
if (code == '0') {
let trackobj = isActivity ? {
...data,
activityId: data.id
} : {
...data,
goodsId: data.id
}
// wx.$Track.setTrack(trackobj, 6)
let activeSku = null
if (data.expressFee != null) data.expressFee = centsToyuan(data.expressFee)
if (isActivity) {
if (data.specificationExtraList && data.specificationExtraList.length) {
activeSku = data.specificationExtraList[0].specificationData
data.skuPrice = centsToyuan(data.specificationExtraList[0].retailPrice)
}
if (data.priceReduce != null) {
data.priceReduce = centsToyuan(data.priceReduce)
let minus = data.priceReduce < 0 ? '-' : ''
if (Math.abs(data.priceReduce) >= 10000) {
let [one, two] = `${Math.abs(data.priceReduce) / 10000}`.split('.')
two = two ? two.substring(0, 2) : '00'
data.priceReduce = `${minus}${one}.${two}万`
}
}
if (data.goodsDetailImageList && data.goodsDetailImageList.length > 1) {
let video = {}
data.goodsDetailImageList.map((e, index) => {
console.log(e)
if (e.resType == 3) {
video = e
data.goodsDetailImageList.splice(index, 1)
data.goodsDetailImageList.unshift(video)
}
})
// data.goodsDetailImageList.unshift(video)
}
} else {
if (data.goodsVideo)
data.goodsDetailImageList = [{
resType: 3,
content: data.goodsVideo
},
...data.goodsDetailImageList
]
if (data.originalPrice != null) data.originalPrice = centsToyuan(data.originalPrice)
// for(let i=0; i<data.specificationList&&data.specificationList.length;i++ ){
// if(data.specificationDetailList[i].stock!=0){
// activeSku = data.specificationDetailList[i].specificationData
// data.skuPrice = centsToyuan(data.specificationDetailList[i].retailPrice)
// }
// }
if (data.specificationList && data.specificationList.length) {
activeSku = data.specificationDetailList[0].specificationData
data.skuPrice = centsToyuan(data.specificationDetailList[0].retailPrice)
}
}
if (data.retailPrice != null) {
data.retailPrice = centsToyuan(data.retailPrice)
if (data.retailPrice >= 10000) {
data.retailPrice = Number(data.retailPrice / 10000).toFixed(2)
data.unit = '万'
}
data.retailPrice = Number(data.retailPrice).toFixed(2)
}
if (data.goodsDescList && data.goodsDescList.length) {
this.setMediaInfo(data.goodsDescList)
}
this.setData({
goodsInfo: data,
goodsFlag: true,
activeSku
})
if (isActivity) this.countDown([data.startTime, data.endTime])
if (!wx.$authStatus) this.getUserAddressDefault()
else
this.setData({
addressFlag: true
})
wx.hideLoading()
} else {
wx.hideLoading()
this.setData({
isLoading: false
})
}
})
},
getGoodscouponList(id) {
id = id ? id : this.data.id
wx.p.api.shopmallApi
.getGoodscouponList({
id
})
.then(({
code,
data,
message
}) => {
let list =
data &&
data.map(item => {
if (item.effectiveEndTime || item.effectiveStartTime) {
item.effectiveEndTime = new Date(item.effectiveEndTime).format('yyyy.MM.dd')
item.effectiveStartTime = new Date(item.effectiveStartTime).format('yyyy.MM.dd')
}
return item
})
this.setData({
couponData: list
})
})
},
setMediaInfo(goodsDescList) {
wx.p.wxApi.getSystemInfo(({
windowWidth
}) => {
goodsDescList.map((e, index) => {
if (e.resType == 3) {
wx.getVideoInfo({
src: e.content
}).then(res => {
let ratio = (windowWidth - 40) / res.width
this.setData({
[`goodsInfo.goodsDescList[${index}].height`]: res.height * ratio
})
})
}
})
})
},
getUserAddressList() {
wx.p.api.mineApi.getUserAddressList().then(data => {
if (!data.length) {
this.setData({
contactAddress: '',
contactInfo: {
contactAddress: '',
contactName: '',
contactPhone: ''
},
isDefault: false
})
}
})
},
getUserAddressDefault() {
wx.p.api.mineApi.getUserAddressDefault().then(({
code,
data
}) => {
if (code == '0') {
let contactAddress = `${data.province}${data.city}${data.area}${data.address}`
this.setData({
contactAddress,
contactInfo: {
contactAddress,
contactName: data.receiveName,
contactPhone: data.phoneNumber
},
isDefault: data.isDefault == 1
})
}
this.setData({
addressFlag: true
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getUserAddressList()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
// wx.p.util.customerbehavior(2)
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
const {
merchantId
} = wx.p.storage.get('merchant_info')
let {
isActivity,
isLive,
goodsInfo
} = this.data
let title = goodsInfo.goodsName
let path = `${this.route}?id=${goodsInfo.id}`
let imageUrl = ''
goodsInfo.goodsDetailImageList.map(e => {
if (e.resType == 1 && !imageUrl) imageUrl = e.content
})
if (isActivity) {
title = goodsInfo.activityName
path = `${path}&isActivity=true`
}
if (isLive) path = `${path}&isLive=true`
if (merchantId) path = `${path}&merchantId=${merchantId}`
return {
imageUrl,
title,
path
}
},
countDown(params) {
let {
activityStatus
} = this.data.goodsInfo
// activityStatus 1:未开始,2进行中,3已结束
const addZero = i => (i < 10 ? `0${i}` : `${i}`)
let [activityStartTime, activityEndTime] = params
const start = iosTimeFormat(activityStartTime)
const end = iosTimeFormat(activityEndTime)
if (new Date().getTime() > new Date(end).getTime() || activityStatus == 3) {
clearTimeout(this.time)
this.setData({
timeFlag: true,
finished: '活动已结束'
})
return
}
if (new Date().getTime() >= new Date(start).getTime() && activityStatus != 2) {
this.setData({
'goodsInfo.activityStatus': 2
})
activityStatus = 2
}
let starTime = new Date()
let endTime = new Date(activityStatus == 2 ? end : start)
let lefttime = parseInt((endTime.getTime() - starTime.getTime()) / 1000)
let d = parseInt(lefttime / (24 * 60 * 60))
let h = parseInt((lefttime / (60 * 60)) % 24)
let m = parseInt((lefttime / 60) % 60)
let s = parseInt(lefttime % 60)
h = addZero(h)
m = addZero(m)
s = addZero(s)
let type = {
1: '距开始',
2: '距结束'
} [activityStatus]
if (this.time) clearTimeout(this.time)
this.time = setTimeout(() => {
let dayList = [h, m, s]
let activityTime = {
dayList,
type
}
if (d > 0) activityTime.day = `${d}天`
this.setData({
activityTime,
timeFlag: true
})
this.countDown(params)
}, 1 * 1000)
}
})
\ No newline at end of file \ No newline at end of file
{
"navigationStyle": "custom",
"usingComponents": {
"coupon-goods": "../../components/CouponGoods/CouponGoods",
"sku": "../../components/Sku/Sku"
}
}
\ No newline at end of file \ No newline at end of file
/* packageMall/pages/detail/detail.wxss */
.flex {
display: flex;
align-items: center;
position: relative;
}
.navigation-bar {
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
.empty-page {
box-sizing: border-box;
width: 100%;
height: calc(100vh - 128rpx);
padding-top: 128rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 28rpx;
color: #ACACAC;
}
.empty-img {
width: 446rpx;
height: 240rpx;
margin-bottom: 60rpx;
}
.navigation {
width: 100%;
height: 100%;
position: relative;
}
.navigation .back {
width: 64rpx;
height: 64rpx;
background: rgba(255, 255, 255, 0.5);
border-radius: var(--margin);
position: absolute;
left: 20rpx;
}
.navigation .back .icon {
width: 36rpx;
height: 36rpx;
}
.navigation .text {
max-width: 50%;
font-size: 32rpx;
color: #333333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: 500;
box-sizing: border-box;
text-align: center;
letter-spacing: 1rpx;
}
.box {
margin-bottom: 16rpx;
background-color: #fff;
}
.banner-box {
height: 750rpx;
position: relative;
}
.banner {
height: 100%;
}
.dot-box {
position: absolute;
bottom: 24rpx;
border-radius: 2rpx;
overflow: hidden;
display: flex;
}
.banner video {
width: 100%;
height: 100%;
}
.dot {
width: 20rpx;
height: var(--borderRadius);
background: rgba(255, 255, 255, 0.3);
transition: all .5s;
}
.dot.active {
background-color: #fff;
}
.activity-box {
height: 100rpx;
position: relative;
}
.activity-box .activity-bg {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.activity-box .activity-info {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 2;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 0 23rpx 0 15rpx;
color: #fff;
}
.activity-box .activity-info .price,
.activity-box .activity-info .now,
.activity-box .activity-info .text {
display: flex;
font-size: 24rpx;
}
.activity-box .activity-info .price {
align-items: baseline;
}
.activity-box .activity-info .text {
align-items: center;
}
.activity-box .activity-info .now {
font-size: 40rpx;
align-items: baseline;
margin-left: var(--borderRadius);
}
.activity-box .activity-info .now .num {
font-size: 60rpx;
line-height: 60rpx;
letter-spacing: -2rpx;
}
.activity-box .activity-info .activity-unit {
font-size: 40rpx;
margin-left: 6rpx;
transform: translateY(-5rpx);
}
.activity-box .activity-info .count {
opacity: .5;
font-size: 20rpx;
transform: translateY(-5rpx);
}
.activity-box .activity-info .text .old {
padding: 0 12rpx;
height: 28rpx;
background: #FFEAD1;
border-radius: 14rpx;
font-size: 20rpx;
color: var(--themeColor);
flex-direction: column;
margin-left: 6rpx;
}
.activity-box .activity-info .activity-time {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 20rpx;
color: var(--themeColor);
animation: show-activity-time .5s forwards;
}
@keyframes show-activity-time {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.activity-box .activity-info .activity-time .time {
font-size: 24rpx;
display: flex;
align-items: center;
justify-content: flex-end;
color: var(--themeColor);
margin-top: 10rpx;
}
.activity-box .activity-info .activity-time .day {
margin-right: var(--borderRadius);
}
.activity-box .activity-info .time-box {
background: var(--themeColor);
border-radius: 4rpx;
width: 36rpx;
height: 36rpx;
color: #fff;
}
.activity-box .activity-info .unit {
text-align: center;
width: 16rpx;
}
.activity-time .finished {
font-size: 32rpx;
}
.goods-info {
padding: 28rpx 40rpx 32rpx;
}
.goods-info .price {
margin-bottom: 2rpx;
}
.goods-info .price,
.goods-info .price .now {
display: flex;
align-items: baseline;
}
.goods-info .price .now {
font-size: 64rpx;
color: var(--btnColor);
margin-right: 8rpx;
line-height: 64rpx;
}
.goods-info .price .now .unit {
font-size: 40rpx;
}
.goods-info .price .now .up {
transform: translateY(-2rpx);
}
.goods-info .price .old {
color: #B1B1B3;
text-decoration: line-through;
}
.goods-info .name {
font-size: 36rpx;
font-weight: 500;
position: relative;
width: 85%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.goods-info .count {
margin-top: 20rpx;
font-size: 24rpx;
color: #B1B1B3;
display: flex;
position: relative;
}
.goods-info .count view:nth-child(2) {
margin-left: 100rpx;
}
.goods-param {
padding: 0 40rpx;
}
.goods-param .item {
position: relative;
height: 98rpx;
border-bottom: 2rpx solid #EFF0F2;
display: flex;
align-items: center;
font-size: 24rpx;
}
.goods-param .item:last-child {
border-bottom: none;
}
.goods-param .item .label {
width: 136rpx;
color: #656566;
}
.goods-param .item .value {
width: 490rpx;
color: #3B3B3D;
}
.goods-param .item .coupon {
font-size: 24rpx;
padding: 0 20rpx;
font-weight: 500;
color: var(--btnColor);
line-height: 40rpx;
height: 40rpx;
width: auto;
background: rgba(252, 91, 50, 0.12);
border-radius: 4rpx;
box-sizing: border-box;
}
.goods-param .address {
height: 134rpx;
align-items: flex-start;
box-sizing: border-box;
padding: var(--margin) 0;
position: relative;
}
.goods-param .address .tips {
position: absolute;
color: #B1B1B3;
left: 136rpx;
bottom: var(--margin);
}
.goods-param .item .icon-mine-arrow {
margin-left: auto;
transform: scale(1.3) translateY(9rpx);
}
.goods-param .address .icon-mine-arrow {
position: absolute;
right: 0;
top: 50%;
transform: scale(1.3) translateY(0);
}
.activity-detail {
background-color: #fff;
}
.activity-detail .title {
display: flex;
align-items: center;
padding: 0 40rpx 20rpx;
}
.activity-detail .title .icon {
width: 32rpx;
height: 32rpx;
margin-right: var(--borderRadius);
}
.detail-time {
margin-bottom: 20rpx;
}
.content {
font-size: 24rpx;
background-color: #fff;
padding: 0 40rpx;
}
.content:first-of-type,
.activity-detail .title:first-of-type {
padding-top: 40rpx;
}
.content:last-of-type {
padding-bottom: 40rpx;
}
.goods-comment {
padding: 40rpx 32rpx;
}
.goods-comment .comment-head {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 12rpx;
}
.goods-comment .comment-content {
font-size: 28rpx;
font-weight: 400;
color: #282829;
line-height: 40rpx;
padding: 0 0 20rpx 0;
white-space:normal;
word-break:break-all;
}
.goods-comment .comment-head .comment-total {
font-size: 32rpx;
font-weight: 500;
color: #282829;
line-height: 44rpx;
}
.comment-all {
font-size: 24rpx;
font-weight: 400;
color: #3B3B3D;
line-height: 34rpx;
display: flex;
align-items: center;
}
.comment-all .icon-mine-arrow {
margin-left: 12rpx;
}
.comment-user {
padding: 16rpx 0 20rpx 0;
display: flex;
align-items: center;
}
.comment-user .user-portrait {
width: 72rpx;
height: 72rpx;
margin-right: 16rpx;
background-color: #333333;
border-radius: 50%;
}
.user-portrait image{
border-radius: 50%;
}
.comment-user .user-info .name {
font-size: 32rpx;
font-weight: 600;
color: #282829;
line-height: 44rpx;
}
.comment-user .user-info .comment-time {
font-size: 20rpx;
font-weight: 400;
color: #B1B1B3;
line-height: 28rpx;
}
.goods-comment .comment-images {
display: flex;
align-items: center;
flex-wrap: wrap;
margin-right: -40rpx;
}
.goods-comment .comment-images .icon {
width: 160rpx;
height: 160rpx;
border-radius: 8rpx;
box-sizing: border-box;
margin-right: 16rpx;
background-color: #e7e7e7;
margin-bottom: 10rpx;
}
.goods-comment .comment-images .icon image {
border-radius: 8rpx;
}
.share {
width: 108rpx;
height: 34rpx;
background: rgba(252, 91, 50, 0.1);
border-radius: 4rpx;
font-size: 24rpx;
color: var(--btnColor);
line-height: 34rpx;
display: flex;
align-items: center;
position: absolute;
right: 0;
padding-left: 12rpx;
box-sizing: border-box;
}
.share text {
flex-shrink: 0;
}
.icon-goods-share {
transform: scale(0.54);
}
.model {
position: fixed;
left: 0;
right: 0;
top: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
width: 100%;
height: 100%;
z-index: 999999;
display: flex;
align-items: center;
justify-content: center;
}
.poster {
width: 540rpx;
height: 860rpx;
border-radius: 8rpx;
}
.hidden{
height:100%;
overflow: hidden;
}
.shop {
height: 62rpx;
background-color: white;
padding: 30rpx;
display: flex;
align-items: center;
border-bottom: 2rpx solid #F7F8FA;
}
.shop .right {
width: 24rpx;
height: 18rpx;
margin: 0 14rpx 0 26rpx;
}
.shop .processBox {
display: flex;
}
.shop .processBox .describe {
margin-left: 8rpx;
}
.shop .processBox .describe .describeTop {
font-size: 24rpx;
color: #333333;
}
.shop .processBox .describe .describeBottom {
font-size: 20rpx;
color: #999999;
}
.shop .processBox image {
width: 60rpx;
height: 60rpx;
}
.goods-param .items {
min-height: 34rpx;
display: flex;
font-size: 24rpx;
padding: 32rpx 0;
}
.goods-param .items .labels {
width: 136rpx;
color: #656566;
}
.goods-param .items .values {
width: 490rpx;
color: #3B3B3D;
}
.tab-widget{
width: 100%;
height: 88rpx;
background: white;
position: fixed;
left: 0;
top: 88rpx;
right: 0;
z-index: 999;
}
.tab-widget .tab-item{
width: 50%;
height: 100%;
position: relative;
}
.tab-widget .tab-item .text{
font-size: 28rpx;
color: #656566;
line-height: 40rpx;
}
.tab-widget .tab-item .text-ative{
font-weight: 500;
font-size: 28rpx;
color: #2C2C2C;
}
.tab-widget .tab-item .line{
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: 66rpx;
height: 6rpx;
background: var(--btnColor);
border-radius: 2rpx;
}
\ No newline at end of file \ No newline at end of file
<view class="navigation-bar">
<navigation-bar custom navStyle="{{navStyle}}" bindnavbarReady="navbarReady" page-title="{{isActivity?goodsInfo.activityName:goodsInfo.goodsName}}">
<view class="navigation">
<view class="back text-center y-center" bindtap="back">
<glsx-image webp src="mall/{{showHomeBtn?'home':'back'}}.png" class="icon"></glsx-image>
</view>
</view>
</navigation-bar>
</view>
<view class="empty-page" wx:if="{{!goodsFlag && !isLoading}}">
<glsx-image webp class="empty-img" src="mall/active-empty.png" />
活动重新配置中,请稍后重试
</view>
<block wx:if="{{goodsFlag}}">
<view class="{{posterUrl==''?'layout':'layout hidden'}} " style="padding-bottom:{{padding_bottom + 20}}px;">
<view class="banner-box">
<swiper class="banner" bindchange="changeBanner">
<block wx:for="{{goodsInfo.goodsDetailImageList}}" wx:key="index">
<swiper-item>
<block wx:if="{{item.resType == 1}}">
<image webp src="{{item.content}}" bindtap="previewImage" data-current="{{item.content}}" data-item="{{goodsInfo.goodsDetailImageList}}"></image>
</block>
<block wx:elif="{{item.resType == 3}}">
<video src="{{item.content}}"></video>
</block>
</swiper-item>
</block>
</swiper>
<block wx:if="{{goodsInfo.goodsDetailImageList.length > 1}}">
<view class="dot-box x-center">
<block wx:for="{{goodsInfo.goodsDetailImageList}}" wx:key="index">
<view class="dot {{bannerIndex == index ? 'active':''}}">
</view>
</block>
</view>
</block>
</view>
<block wx:if="{{isActivity}}">
<view class="activity-box">
<view class="activity-info">
<view class="price-info">
<view class="price">
<text>秒杀价</text>
<view class="text">
<view class="now">
<text>¥</text>
<view class="num">{{goodsInfo.retailPrice}}</view>
<block wx:if="{{goodsInfo.unit}}">
<view class="activity-unit">{{goodsInfo.unit}}</view>
</block>
</view>
<view class="old text-center">
限时直降{{goodsInfo.priceReduce}}
</view>
</view>
</view>
<view class="count">已售出{{goodsInfo.saleAmount || 0}}件</view>
</view>
<!-- activityStatus:1:未开始,2进行中,3已结束 -->
<block wx:if="{{goodsInfo.activityStatus != 3}}">
<view class="activity-time" wx:if="{{timeFlag}}">
<view class="title">{{activityTime.type}}还剩:</view>
<view class="time">
<view class="day">{{activityTime.day || ''}}</view>
<block wx:for="{{activityTime.dayList}}" wx:key="index">
<view class="time-box text-center">
{{item}}
</view>
<view class="unit" wx:if="{{index < 2}}"> :</view>
</block>
</view>
</view>
</block>
<block wx:else>
<view class="activity-time">
<view class="finished">{{finished}}</view>
</view>
</block>
</view>
<view class="activity-bg">
<glsx-image webp src="mall/activity.png"></glsx-image>
</view>
</view>
</block>
<view class="goods-info box">
<block wx:if="{{!isActivity}}">
<view class="price">
<view class="now">
<text class="unit">¥</text>
<block wx:if="{{activeSku}}">
{{goodsInfo.skuPrice}}
<text class="unit up">起</text>
</block>
<block wx:else>{{goodsInfo.retailPrice}}</block>
</view>
<view class="old">¥{{goodsInfo.originalPrice}}</view>
</view>
</block>
<view class="flex">
<view class="name"> {{isActivity?goodsInfo.activityName:goodsInfo.goodsName}}
</view>
</view>
<block wx:if="{{!isActivity}}">
<view class="count">
<view>剩余: {{goodsInfo.goodsStock || goodsInfo.specificationDetailList[0].stock || 0}}</view>
<view>销售: {{goodsInfo.goodsStatistics.saleAmount || 0}}</view>
</view>
</block>
</view>
<view class="goods-param box">
<block wx:if="{{!isActivity}}">
<block wx:if="{{couponData.length>0}}">
<view class="item" bindtap="showCouponFun">
<view class="label">优惠</view>
<view class="value coupon">优惠券</view>
<view class="sprite-icon icon-mine-arrow"></view>
</view>
</block>
</block>
<block wx:if="{{activeSku}}">
<view class="item" bindtap="showSkuFun">
<view class="label">已选</view>
<view class="value text-hide">{{activeSku}}</view>
<view class="sprite-icon icon-mine-arrow"></view>
</view>
</block>
<block wx:if="{{goodsInfo.deliveryType != 1}}">
<view class="item address" bindtap="jump" data-url="/packageMine/pages/address/index/index" data-is-choose-address>
<view class="label">配送</view>
<view class="value text-hide">
<block wx:if="{{addressFlag}}">
{{contactAddress||'填写地址'}}
</block>
</view>
<view class="tips">支付后,预计48小时内发货</view>
<view class="sprite-icon icon-mine-arrow"></view>
</view>
</block>
<block wx:if="{{goodsInfo.deliveryType != 1}}">
<view class="item">
<view class="label">运费</view>
<view class="value text-hide">
<block wx:if="{{goodsInfo.expressFee}}">{{goodsInfo.expressFee}}元</block>
<block wx:else>免运费(请以提交订单时为准)</block>
</view>
</view>
</block>
<block wx:if="{{isActivity && goodsInfo.limitPurchaseFlag == 2}}">
<view class="item">
<view class="label">说明</view>
<view class="value text-hide">
<text>此商品活动期间每人限购{{goodsInfo.limitPurchaseNumber}}件</text>
</view>
</view>
</block>
<block wx:if="{{goodsInfo.serviceDesc}}">
<view class="items">
<view class="labels">服务说明</view>
<view class="values">
<text>{{goodsInfo.serviceDesc}}</text>
</view>
</view>
</block>
</view>
<view class="activity-detail">
<block wx:if="{{isActivity}}">
<view class="title">
<view class="sprite-icon icon-goods-time"></view>
活动时间
</view>
<view class="content detail-time">
{{goodsInfo.startTime}} - {{goodsInfo.endTime}}
</view>
<view class="title">
<view class="sprite-icon icon-goods-text"></view>
活动详情
</view>
</block>
<block wx:for="{{goodsInfo.goodsDescList}}" wx:key="index">
<view class="content">
<block wx:if="{{item.resType == 1}}">
<image webp src="{{item.content}}" mode="widthFix" bindtap="previewImage" data-current="{{item.content}}" data-item="{{goodsInfo.goodsDescList}}" lazy-load></image>
</block>
<block wx:elif="{{item.resType == 2}}">
{{item.content}}
</block>
<block wx:else>
<video src="{{item.content}}" style="height:{{item.height}}px;"></video>
</block>
</view>
</block>
</view>
</view>
</block>
<coupon-goods show="{{showCoupon}}" only="{{only}}" couponData="{{couponData}}" bindclick="showCouponFun"></coupon-goods>
<block wx:if="{{navHeight && goodsFlag}}">
<goods-action bindready="goodsActionReady" pay-disabled="{{goodsInfo.activityStatus != 2 }}" stock="{{goodsInfo.goodsStock === 0}}" buyFlag="{{goodsInfo.buyFlag == 2}}" bindclick="goodsActionClick" hideShop="{{isActivity}}"></goods-action>
<block wx:if="{{activeSku}}">
<sku show="{{showSku}}" showName="showSku" isActivity="{{isActivity}}" skuData="{{goodsInfo}}" bindpay="pay" bindjoin="join"></sku>
</block>
</block>
\ No newline at end of file \ No newline at end of file
// packageMall/pages/search/search.js
Page({
/**
* 页面的初始数据
*/
data: {
searchList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData(options)
this.getSearchList(options.value)
},
getSearchList(value) {
wx.p.wxApi.showLoading()
let {
goodsList
} = this.data
const searchList = []
goodsList.map(e => {
if (e.goodsName.indexOf(value) != -1) searchList.push(e)
})
this.setData({
searchList,
flag: true
})
wx.hideLoading()
},
search(e) {
this.getSearchList(e.detail)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {
"search-box": "/pages/tab/mall/components/SearchBox/SearchBox",
"goods": "/pages/tab/mall/components/Goods/Goods"
}
}
\ No newline at end of file \ No newline at end of file
/* packageMall/pages/search/search.wxss */
.box{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: var(--margin) 60rpx;
}
.goods{
width: 252rpx;
padding: 18rpx;
margin-bottom: 18rpx;
background-color: #fff;
}
\ No newline at end of file \ No newline at end of file
<view class="layout">
<view class="sticky">
<search-box bindsearch="search" search-type="2" value="{{value}}"></search-box>
</view>
<view class="box">
<block wx:if="{{flag}}">
<block wx:if="{{searchList.length}}">
<block wx:key="index" wx:for="{{searchList}}">
<view class="goods">
<goods item="{{item}}"></goods>
</view>
</block>
</block>
<block wx:else>
<view class="list-nothing ">
<view class="list-not">没找到相关商品</view>
</view>
</block>
</block>
</view>
</view>
\ No newline at end of file \ No newline at end of file
Page({
data: {
couponsList: []
},
toReciveAll() {
let para = {
couponIdList: this.data.ids
}
wx.p.api.couponsApi.toReciveCard(para).then(res => {
if (res) {
wx.p.router.go('/packageMine/pages/coupon/success/success')
}
})
},
/**获取礼券 */
getCoupons() {
let para = {
discountTypes: [3]
}
let ids = []
wx.p.api.couponsApi.getHomeCardData(para).then(res => {
res.list.map(item => {
if (item.effectiveStartTime) {
item.effectiveStartTime = new Date(item.effectiveStartTime).format('yyyy.MM.dd')
item.effectiveEndTime = new Date(item.effectiveEndTime).format('yyyy.MM.dd')
}
ids.push(item.id)
return item
})
this.setData({
couponsList: res.list,
ids
})
})
},
onLoad() {
this.getCoupons()
}
})
{
"navigationBarTitleText": "领券中心",
"usingComponents": {
"coupon-item": "../components/CouponsItem/element"
}
}
\ No newline at end of file \ No newline at end of file
page {
background: #F7F8FA;
}
.center-page {
box-sizing: border-box;
padding: 0 32rpx;
}
.btn_wrapper {
/* width: calc(100% - 64rpx); */
width: 100%;
background: var(--btnColor);
height: 88rpx;
text-align: center;
line-height: 88rpx;
border-radius: 8rpx;
font-size: 32rpx;
color: #FFFFFF;
margin-top: 100rpx;
margin-bottom: 210rpx;
/* position: fixed;
bottom: 210rpx;
left: 50%;
transform: translate(-50%, 0);
z-index: 10; */
}
\ No newline at end of file \ No newline at end of file
<view class="center-page">
<block wx:for="{{couponsList}}" wx:key="index">
<coupon-item mode="center" coupons="{{item}}"></coupon-item>
</block>
<view class="btn_wrapper" bind:tap="toReciveAll">一键领取</view>
</view>
\ No newline at end of file \ No newline at end of file
Component({
properties: {
coupons: {
type: Object,
value: {}
},
mode: {
type: String,
value: 'coupon' //coupon卡券 center领券中心
},
btnStatus: {
type: Number,
value: 0
},
useMemberType: Number,
hideBtn: Boolean,
couponStyle: String
},
data: {
// 2 折扣券,3 代金券,4 兑换券,7 服务券
IMGURL: wx.$imgUrl
},
methods: {
toRecive() {
let para = {
couponIdList: [this.data.coupons.id]
}
wx.p.api.couponsApi.toReciveCard(para).then(res => {
if (res) {
wx.p.router.go('/packageMine/pages/coupon/success/success')
}
})
},
toDetail() {
let {
coupons,
useMemberType
} = this.data, {
discountType,
useChannel,
id
} = coupons, detailInfo = {
xx: 'xx'
}
if (discountType == 2 || discountType == 4) {
wx.$router.go('/packageMall/pages/coupon/coupon', {
userCouponId: id,
useMemberType,
detailInfo
})
return
}
/**线上商品代金券 */
if (discountType == 3 && useChannel == 1) {
wx.$router.go('/packageMine/pages/coupon/recommend/recommend', {
couponInfo: coupons
})
return
}
wx.$router.go('/packageMine/pages/coupon/detail/detail', {
item: coupons
})
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true
}
\ No newline at end of file \ No newline at end of file
<!-- <view class="box_wrapper" style="{{couponStyle}}; background-image: url({{btnStatus == 0 ? couponBaseList[coupons.discountType]:unCouponBaseList[coupons.discountType]}});"> -->
<view class="box_wrapper" style="{{couponStyle}}">
<view class="bg">
<image webp src="{{IMGURL}}mine/coupon/{{btnStatus == 0 ? '' :'un-'}}coupon-{{coupons.discountType}}.png?v={{img_version}}"></image>
</view>
<view class="container">
<view class="{{coupons.discountType==4 || coupons.discountType==7 ? '':'left_icon_box'}}">
<!-- <image wx:if="{{btnStatus==0}}" class="left_bg" src="../../packageMine/images/coupons/coupons_active.png" />
<image wx:else class="left_bg" src="../../packageMine/images/coupons/coupons.png" /> -->
<!-- <view wx:if="{{coupons.discountType==7}}" class="left_text_one left_text_four">
<text class="anText">券</text>
<text wx:if="{{coupons.useType&&coupons.effectiveType!=3}}">{{ coupons.usedAmount }}/{{ coupons.useAllAmount }}</text>
<text wx:else>不限次数</text>
</view> -->
<view wx:if="{{coupons.discountType==3}}" class="left_text_one left_text_two {{btnStatus == 0 ? 'brightColor':'darkColor'}}">
<text class="price_icon">¥</text>
<text>{{coupons.denomination}}</text>
</view>
<view wx:if="{{coupons.discountType==2}}" class="left_text_one left_text_two {{btnStatus == 0 ? 'brightColor':'darkColor'}}">
<!-- <text class="anText">券</text> -->
<text class="anText" wx:if="{{coupons.discountIntensity}}">{{coupons.discountIntensity}}</text>
<text class="discount" wx:if="{{coupons.discountIntensity}}">折</text>
</view>
<!-- <view class="left_text_one">8.5折</view> -->
<!-- <view class="left_text_one left_text_two">
</view> -->
<!-- <view class="left_text_one left_text_three">满99可用</view> -->
</view>
<view class="main_box {{coupons.discountType==4 || coupons.discountType==7 ? 'leftMargin':''}}">
<view class="title_text {{btnStatus == 0 ? 'brightColor':'darkColor'}}">{{coupons.couponName}}</view>
<view wx:if="{{coupons.useType==0 && coupons.discountType==7}}" class="h4_text {{btnStatus == 0 ? 'describeColor':'darkColor'}}">不限次数</view>
<view wx:if="{{coupons.useType==1 && coupons.discountType==7}}" class="h4_text {{btnStatus == 0 ? 'describeColor':'darkColor'}}">可用{{coupons.useAmount}}次</view>
<view wx:if="{{coupons.useType==2 && coupons.discountType==7}}" class="h4_text {{btnStatus == 0 ? 'describeColor':'darkColor'}}">{{coupons.useLimitDays}}天可用{{coupons.useAmount}}次</view>
<!-- <view wx:if="{{coupons.discountType==3}}" style="height:1px" class="drive"></view> -->
<view wx:if="{{coupons.useBarriers==1 && coupons.discountType!=4}}" class="h4_text {{btnStatus == 0 ? 'describeColor':'darkColor'}}">无门槛</view>
<view wx:if="{{coupons.useBarriers==2 && coupons.discountType!=4}}" class="h4_text {{btnStatus == 0 ? 'describeColor':'darkColor'}}">满{{coupons.full}}元可用</view>
<view wx:if="{{coupons.effectiveType==3}}" class="h4_text {{btnStatus == 0 ? 'describeColor':'darkColor'}}">永久有效</view>
<view wx:if="{{coupons.effectiveType==2}}" class="h4_text {{btnStatus == 0 ? 'describeColor':'darkColor'}}">{{coupons.receiveStartTime}}-{{coupons.receiveEndTime}}</view>
<view wx:if="{{coupons.effectiveType==1}}" class="h4_text {{btnStatus == 0 ? 'describeColor':'darkColor'}}">有效期至{{coupons.receiveEndTime}}</view>
<!-- <view wx:else class="h4_text drive">{{coupons.receiveStartTime}}-{{coupons.receiveEndTime}}</view> -->
<!-- <view wx:if="{{coupons.effectiveType==1}}" class="h4_text drive">{{coupons.effectiveStartTime}}-{{coupons.effectiveEndTime}}</view> -->
</view>
<!-- <view wx:if="{{mode=='center'}}" class="box_btn box_btn_color" bind:tap="toRecive">领取</view> -->
<block wx:if="{{!hideBtn}}">
<view wx:if="{{mode=='coupon'&&btnStatus==0}}" class="box_btn box_btn_color" bind:tap="toDetail">去使用</view>
<view wx:if="{{mode=='coupon'&&btnStatus==1}}" class="box_btn box_btn_color box_btn_color_grey" bind:tap="toDetail">去查看</view>
<view wx:if="{{mode=='coupon'&&btnStatus==2}}" class="box_btn box_btn_color box_btn_color_grey" bind:tap="toDetail">去查看</view>
</block>
</view>
</view>
\ No newline at end of file \ No newline at end of file
page {
background: white;
}
.box_wrapper {
width: 100%;
height: 162rpx;
/* background: #FFFFFF; */
/* border-radius: 8rpx; */
margin-top: 19rpx;
display: flex;
align-items: center;
position: relative;
box-sizing: border-box;
background-size: cover;
}
.left_icon_box {
width: 156rpx;
height: 156rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.left_bg {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 156rpx;
height: 156rpx;
z-index: 1;
}
.left_text_one {
font-size: 48rpx;
font-weight: 600;
z-index: 2;
}
.left_text_two {
display: flex;
align-items: flex-end;
}
.left_text_four {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.left_text_three {
font-size: 20rpx;
margin-top: 6rpx;
}
.left_tran {
transform: translateX(-120rpx);
}
.anText {
font-size: 48rpx;
/* color: rgba(white, white, white, 0.45); */
font-weight: 600;
/* color: #FFF; */
/* opacity: 0.45; */
}
.price_icon {
font-size: 24rpx;
/* margin-right: 4rpx; */
margin-bottom: 7rpx;
font-weight: 500;
}
.main_box {
height: 156rpx;
box-sizing: border-box;
padding: 24rpx 24rpx 24rpx 0rpx;
justify-content: space-evenly;
display: flex;
flex-direction: column;
z-index: 1;
}
.box_btn {
position: absolute;
right: 47rpx;
top: 50%;
transform: translate(0, -50%);
width: 120rpx;
height: 44rpx;
/* background: #B1B1B3; */
text-align: center;
line-height: 44rpx;
font-size: 28rpx;
font-weight: 600;
}
.box_btn_color {
/* background: var(--btnColor); */
color: var(--btnColor);
}
.box_btn_color_grey {
color: #6D6D6D;
}
.title_text {
color: #282829;
font-weight: 600;
color: #282829;
font-size: 28rpx;
width: 309rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.h4_text {
font-weight: 400;
color: #B1B1B3;
font-size: 20rpx;
}
.leftMargin {
padding-left: 32rpx;
}
.brightColor {
color: var(--btnColor);
}
.darkColor {
color: #6D6D6D;
}
.describeColor {
color: #D83C14;
}
.discount {
font-size: 20rpx;
font-weight: 500;
margin-bottom: 10rpx;
}
.box_wrapper .bg{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.box_wrapper .container {
display: flex;
align-items: center;
position: relative;
z-index: 1;
width: 100%;
height: 100%;
}
import QR from '~/lib/wxqrcode'
Page({
data: {
coupon: {
discountType: 7
},
detailInfo: {},
failure: false,
future: false,
dayDiff: 0,
hourDiff: 0,
minDiff: 0
},
jump(e) {
let { item } = e.currentTarget.dataset
wx.openLocation({
latitude: item.lat,
longitude: item.lng,
name: item.merchantName,
address: item.merchantAddress
})
},
getDetailData(id) {
let para = {
userCouponId: id
}
wx.$api.showLoading('加载中...')
wx.p.api.couponsApi.couponsDetail(para).then(res => {
wx.hideLoading()
let qrcodeURL = QR.createQrCodeImg(`t=2&c=${res.verificationCode}`)
let failure = false
let future = false
res.receiveTime = new Date(res.receiveTime).format('yyyy.MM.dd hh:mm:ss')
res.verificationCode = res.verificationCode.replace(/(.{4})/g, '$1 ')
if (res.couponState == 2) {
failure = true
} else if (res.couponState == 1) {
failure = false
} else if (res.couponState == 3) {
future = true
} else if (res.couponState == 4) {
future = true
} else if (res.couponState == 5) {
failure = true
}
let dayDiff = 0
let hourDiff = 0
let minDiff = 0
if (future) {
dayDiff = res.nextLimitDays
hourDiff = res.nextLimitHours
minDiff = res.nextLimitMin
}
if (res.list.length) {
res.list.map(el => {
el.verificationTime = new Date(el.verificationTime).format('yyyy-MM-dd hh:mm:ss')
return el
})
}
res.receiveEndTime = new Date(res.receiveEndTime).format('yyyy.MM.dd hh:mm:ss')
res.receiveStartTime = new Date(res.receiveStartTime).format('yyyy.MM.dd hh:mm:ss')
this.setData({
detailInfo: res,
future,
failure,
dayDiff,
hourDiff,
minDiff,
qrcodeURL,
coupon: res,
flag: true
})
})
},
onLoad(options) {
let couponInfo = options.item
this.getDetailData(couponInfo.id)
this.setData({
couponInfo
})
// wx.$Track.setTrack(
// {
// couponInfo
// },
// 6
// )
}
})
{
"navigationBarTitleText": "卡券详情",
"usingComponents": {
"coupon-item": "../components/CouponsItem/element"
}
}
\ No newline at end of file \ No newline at end of file
page {
background: #F7F8FA !important;
/* background: #f5f5f5; */
}
.detail-page {
box-sizing: border-box;
padding: 32rpx 32rpx 20rpx;
}
.an-page {
box-sizing: border-box;
padding: 32rpx;
}
.wrapper {
width: 100%;
background: #FFFFFF;
border-radius: 8rpx;
}
.top_element_wrap {
display: flex;
box-sizing: border-box;
border-bottom: 2rpx solid #EFF0F2;
}
.coupon {
height: 196rpx;
border-radius: 8rpx;
margin: 0 32rpx;
}
.icon_box {
width: 156rpx;
height: 156rpx;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.ele_icon {
position: absolute;
width: 100%;
height: 100%;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 1;
}
.icon_text {
font-size: 36rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #FFFFFF;
position: relative;
z-index: 2;
}
.ele_conetent_box {
box-sizing: border-box;
padding-left: 20rpx;
}
.title_wrap {
margin-top: 64rpx;
box-sizing: border-box;
padding-left: 20rpx;
}
.code_wrap {
margin-top: 36rpx;
box-sizing: border-box;
width: 100%;
text-align: center;
}
.code-text {
font-size: 64rpx;
font-family: DINAlternate-Bold, DINAlternate;
font-weight: bold;
color: var(--btnColor);
letter-spacing: 20rpx;
}
.code_box {
width: calc(100% - 64rpx);
height: 140rpx;
background: #979797;
margin: 0 auto;
margin-top: 36rpx;
}
.html-wrap {
width: 100%;
box-sizing: border-box;
padding: 0 20rpx;
word-wrap: break-word;
}
.title-text {
font-size: 28rpx;
font-weight: 600;
color: #282829;
margin-top: 4rpx;
}
.min-text {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #B1B1B3;
margin-top: 2rpx;
}
.date-text {
margin-top: 38rpx;
}
.code-tip {
margin-top: 10rpx;
text-align: center;
}
.drive_line {
width: 100%;
height: 2rpx;
background: #EFF0F2;
}
.shop_info_wrap {
box-sizing: border-box;
padding: 0 20rpx;
margin-top: 24rpx;
}
.shop_header {
display: flex;
align-items: center;
}
.header_img {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
}
.shop_title {
color: #282829;
font-size: 28rpx;
padding-left: 28rpx;
font-weight: 400;
}
.shop_adress {
width: 100%;
font-size: 24rpx;
font-weight: 400;
color: #656566;
margin-top: 24rpx;
}
.shop_date {
font-size: 24rpx;
font-weight: 400;
color: #656566;
margin-top: 8rpx;
}
/* 服务券 */
.other_wrapper {
width: 100%;
}
.an_title_text {
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 20rpx;
}
.an_min_title_text {
text-align: center;
font-size: 22rpx;
font-weight: 500;
color: #B1B1B3;
margin-top: 10rpx;
}
/* .code_widget {
width: 100%;
height: 364rpx;
box-sizing: border-box;
background: #FEFFFE;
border-radius: 8rpx;
margin-top: 32rpx;
padding: 32rpx 0;
padding-top: 32rpx;
padding-bottom: 32rpx;
position: relative;
} */
.code_failture {
position: absolute;
left: 50%;
top: 154rpx;
transform: translate(-50%, 0);
padding: 10rpx 44rpx;
color: #FFFFFF;
background: #999999;
border-radius: 16rpx;
}
.code_future {
position: absolute;
left: 50%;
top: 144rpx;
transform: translate(-50%, 0);
padding: 10rpx 50rpx;
color: var(--btnColor);
background: #FDDED5;
border-radius: 16rpx;
}
.code_text_red {
font-size: 28rpx;
text-align: center;
line-height: 40rpx;
}
.mar5 {
margin-bottom: 10rpx;
}
.iamge_qr_wrap {
width: 280rpx;
height: 280rpx;
position: relative;
margin: 24rpx auto;
}
.qrcodeimage {
width: 280rpx;
height: 280rpx;
}
.qrBtn {
/* position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 236rpx;
height: 64rpx; */
display: flex;
/* align-items: center; */
justify-content: center;
/* background: #FFFFFF;
border: 2rpx solid #979797;
box-shadow: 0px 4rpx 8rpx 0px rgba(0, 0, 0, 0.29);
border-radius: 16rpx; */
font-size: 28rpx;
margin: 24rpx 0 12rpx;
/* line-height: 40px; */
/* color: #656566;
font-weight: 400; */
}
.qrBtns {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
font-weight: 400;
color: #FFFFFF;
line-height: 32rpx;
width: 181rpx;
height: 84rpx;
background: #000;
border-radius: 8rpx;
opacity: 0.7;
}
.op30 {
opacity: 0.3;
}
.qrText {
color: var(--btnColor);
}
.code_main_text {
text-align: center;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
}
.count_text {
margin-left: 10rpx;
font-weight: 600;
}
/* .useed_widget {
width: 100%;
height: 554rpx;
box-sizing: border-box;
background: #FEFFFE;
margin-top: 32rpx;
padding: 32rpx 0;
border-radius: 8rpx;
} */
.step_wrapper {
display: flex;
align-items: center;
justify-content: center;
margin-top: 40rpx;
}
.step_icon {
width: 92rpx;
height: 92rpx;
margin-bottom: 20rpx;
}
.step_arrpw {
width: 46rpx;
height: 33rpx;
margin: 0 24rpx;
}
.step_box {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.desc_wrapper {
padding: 0 24rpx;
color: #B1B1B3;
font-size: 28rpx;
margin-top: 40rpx;
}
.note_line {
box-sizing: border-box;
/* padding: 0 24rpx; */
/* margin-bottom: 20rpx; */
line-height: 48rpx;
/* display: flex;
align-items: center;
justify-content: space-between; */
}
.line_text {
font-size: 24rpx;
color: #666;
}
.price_icon {
font-size: 20rpx;
margin-right: 4rpx;
}
.code_text_grey {
color: #B1B1B3;
}
.box {
padding: 0 32rpx 40rpx 32rpx;
}
.box-X {
border-radius: 8rpx;
background-color: #fff;
padding: 24rpx 24rpx 40rpx;
}
.box .title {
font-size: 32rpx;
padding-bottom: 24rpx;
font-weight: 500;
}
.box .goods {
margin-top: 24rpx;
display: flex;
align-items: center;
height: 160rpx;
}
.box .goods .icon {
width: 160rpx;
height: 100%;
overflow: hidden;
border-radius: 8rpx;
margin-right: 20rpx;
}
.box .goods .info {
width: calc(100% - 180rpx);
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.box .goods .info .name {
font-size: 30rpx;
color: #333;
}
.box .goods .info .price {
display: flex;
color: var(--btnColor);
font-weight: 500;
}
.box .goods .info .price-X {
margin-top: -8rpx;
font-size: 36rpx;
font-family: DINAlternate-Bold, DINAlternate;
}
.couponBox {
border-radius: 8rpx;
background-color: #fff;
padding: 32rpx 32rpx 20rpx 32rpx;
margin: 0 0 20rpx;
box-shadow: 0rpx 8rpx 16rpx 0rpx rgba(224, 224, 224, 0.5);
}
.note_line .line_text_name {
font-size: 28rpx;
color: #333;
}
.note_line .line {
height: 2rpx;
background: #EEE;
margin: 16rpx 0 14rpx;
}
.couponBox .couponBox-X {
max-width: 610rpx;
line-height: 48rpx;
}
.couponBox .couponBox-X .titleDay {
font-size: 28rpx;
font-weight: 500;
color: #333;
}
.titleDay_text {
font-size: 24rpx;
color: #666;
}
.darkColor {
color: #666;
}
.couponBox .title {
font-size: 32rpx;
font-weight: 500;
color: #333;
}
.couponBox .store-box {
background: #F9F9F9;
border: 2rpx solid #E9E9E9;
border-radius: 8rpx;
padding: 16rpx 32rpx;
margin-bottom: 18rpx;
}
.couponBox .store-box:last-child {
margin-bottom: 0;
}
.couponBox .storeName {
font-size: 28rpx;
color: #333;
margin-bottom: 8rpx;
}
.couponBox .businessTime {
font-size: 24rpx;
color: #999;
padding-bottom: 18rpx;
}
.couponBox .line {
height: 2rpx;
background: #EEE;
}
.couponBox .addressBox {
padding-top: 20rpx;
font-size: 24rpx;
color: #666;
display: flex;
align-items: center;
}
.couponBox .addressBox .navigation {
width: 32rpx;
height: 32rpx;
}
.timeColor {
color: #999;
}
.changeColor {
color: #333;
}
.numberColor {
color: #B4B4B4;
}
.couponBox .topBox {
display: flex;
}
.couponBox .topBox .baseImage {
width: 140rpx;
height: 138rpx;
background-size: cover;
position: absolute;
right: 24rpx;
top: 22rpx;
}
.couponBox .topBox .title_text {
font-size: 36rpx;
font-weight: 600;
margin-bottom: 20rpx;
max-width: 510rpx;
}
.couponBox .lines {
height: 2rpx;
background: #EEE;
margin: 32rpx 0 30rpx;
}
.couponBox .process {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 4rpx;
}
.process .process_text {
margin-left: 4rpx;
font-size: 24rpx;
color: #333;
}
.process image {
width: 24rpx;
height: 24rpx;
}
.process .rightArrow {
padding: 0 40rpx;
}
\ No newline at end of file \ No newline at end of file
<block wx:if="{{flag}}">
<view class="detail-page">
<!-- <view wx:if="{{coupon.discountType!=7}}" class="wrapper">
<view class="top_element_wrap">
<coupon-item coupons="{{couponInfo}}" hideBtn ></coupon-item>
</view>
<block wx:if="{{coupon.useChannel != 1}}">
<view class="title_wrap">
<view class="title-text">核销码</view>
</view>
<view class="code_wrap">
<text class="code_text_red {{failure || future?'code_text_grey':''}}">{{detailInfo.verificationCode}}</text>
<view wx:if="{{!failure&&!future}}" class="code-tip min-text">请将核销码拿给店员,避免泄露给他人</view>
<view wx:if="{{qrcodeURL}}" class="iamge_qr_wrap">
<image webp class="qrcodeimage {{failure || future?'op30':''}}" src="{{qrcodeURL}}" />
<view wx:if="{{failure}}" class="qrBtn">{{detailInfo.couponState==5?'已使用':'已失效'}}</view>
<view wx:if="{{future}}" class="qrBtn qrText">
<text wx:if="{{dayDiff}}">{{dayDiff}}天</text>
<text wx:if="{{hourDiff}}">{{hourDiff}}时</text>
<text wx:if="{{minDiff}}">{{minDiff}}分</text>
<text>后可用</text>
</view>
</view> -->
<!-- <view wx:if="{{failure}}" class="code_text_grey">已失效</view>
<view wx:if="{{future}}" class="code_future">
<text wx:if="{{dayDiff}}">{{dayDiff}}天</text>
<text wx:if="{{hourDiff}}">{{hourDiff}}时</text>
<text wx:if="{{minDiff}}">{{minDiff}}分</text>
<text>后可用</text>
</view> -->
<!-- </view>
</block>
<view class="title_wrap">
<view class="title-text">使用说明</view>
<view class="html-wrap">{{detailInfo.useDescription || ''}}</view>
</view>
<view style="height:64rpx"></view>
<view class="drive_line"></view>
<view class="title_wrap">
<view class="title-text">适用门店</view>
</view>
<view class="shop_info_wrap">
<view class="shop_header">
<image webp class="header_img" src="../../../images/success.png" />
<view class="shop_title">{{detailInfo.merchantName}}</view>
</view>
<view class="shop_adress">{{detailInfo.merchantAddress || ''}}</view>
<view wx:if="{{detailInfo.bussinessBegintime}}" class="shop_date">营业时间:{{detailInfo.bussinessBegintime}}-{{detailInfo.bussinessEndtime}}</view>
<view wx:else class="shop_date">营业时间:无</view>
</view>
<view style="height:48rpx"></view>
</view> -->
<view class="other_wrapper">
<!-- <view class="an_title_text">{{detailInfo.merchantName}}</view>
<view class="an_min_title_text">获取时间 {{detailInfo.receiveTime}}</view> -->
<view class="couponBox">
<view class="topBox">
<view class="title_text {{coupon.useMemberType == 0 ? 'qrText':'changeColor'}}">{{detailInfo.couponName}}</view>
<!-- <view class="baseImage" style="background-image: url({{coupon.useMemberType == 0 ? couponBaseList[couponInfo.discountType]:unCouponBaseList[couponInfo.discountType]}});"></view> -->
<glsx-image webp class="baseImage" src="mine/coupon/{{coupon.useMemberType == 0 ? '':'un-'}}{{couponInfo.discountType}}.png"></glsx-image>
</view>
<!-- <view class="an_min_title_text mar5">到店使用服务后请出示该核销码给店员进行核销</view> -->
<view wx:if="{{couponInfo.effectiveType==3 || coupon.effectiveType==3}}" class="titleDay_text timeColor">永久有效</view>
<view wx:if="{{couponInfo.effectiveType==2 || coupon.effectiveType==2}}" class="titleDay_text timeColor">{{detailInfo.receiveStartTime || coupon.receiveStartTime}}-{{detailInfo.receiveEndTime || coupon.receiveEndTime}}</view>
<view wx:if="{{couponInfo.effectiveType==1 || coupon.effectiveType==1}}" class="titleDay_text timeColor">有效期至{{detailInfo.receiveEndTime || coupon.receiveEndTime}}</view>
<view class="lines"></view>
<block wx:if="{{coupon.discountType == 7}}">
<view wx:if="{{detailInfo.useType && !(detailInfo.effectiveType == 3 && detailInfo.useType == 2)}}" class="code_main_text {{coupon.useMemberType == 0 ? 'qrText':'changeColor'}}">
<text>剩余可用</text>
<view class="count_text">{{detailInfo.useAllAmount - detailInfo.usedAmount}}/{{detailInfo.useAllAmount}}</view>
<text>次</text>
</view>
<view wx:else class="code_main_text {{coupon.useMemberType == 0 ? 'qrText':'changeColor'}}">不限次数</view>
</block>
<block wx:else>
<view class="code_main_text {{coupon.useMemberType == 0 ? 'qrText':'changeColor'}}">
<text style="font-size: 24rpx; margin-top: 10rpx;">¥</text>
<view style="font-size: 40rpx; margin-right: 10rpx;">{{coupon.denomination / 100}}</view>
<text>无门槛</text>
</view>
</block>
<view wx:if="{{qrcodeURL}}" class="iamge_qr_wrap">
<glsx-image webp wx:if="{{future}}" class="qrcodeimage" src="mine/qrCode.png" />
<image wx:else class="qrcodeimage" src="{{qrcodeURL}}" />
<view wx:if="{{failure}}" class="qrBtns">{{detailInfo.couponState==5?'已使用':'已失效'}}</view>
</view>
<view wx:if="{{future}}" class="qrBtn">
<text wx:if="{{dayDiff}}" class="qrText">{{dayDiff}}</text>
<text wx:if="{{dayDiff}}">天</text>
<text wx:if="{{hourDiff}}" class="qrText">{{hourDiff}}</text>
<text wx:if="{{hourDiff}}">时</text>
<text wx:if="{{minDiff}}" class="qrText">{{minDiff}}</text>
<text wx:if="{{minDiff}}">分</text>
<text>后可用</text>
</view>
<view class="code_text_red {{coupon.useMemberType == 0 ? 'darkColor':'numberColor'}}">
{{detailInfo.verificationCode}}
</view>
<view class="lines" style="margin: 20rpx 0 18rpx;"></view>
<view class="process">
<glsx-image webp src="mine/{{coupon.useMemberType == 0 ? 'arrows':'unArrow'}}.png"></glsx-image>
<text class="process_text">导航到店</text>
<glsx-image webp class="rightArrow" src="mine/rightArrow.png" />
<glsx-image webp src="mine/{{coupon.useMemberType == 0 ? 'car':'unCar'}}.png"></glsx-image>
<text class="process_text">开始服务</text>
<glsx-image webp class="rightArrow" src="mine/rightArrow.png" />
<glsx-image webp src="mine/{{coupon.useMemberType == 0 ? 'ticket':'unTicket'}}.png"></glsx-image>
<text class="process_text">出示核销码</text>
</view>
<!-- <view wx:if="{{failure}}" class="code_failture">已失效</view> -->
<!-- <view wx:if="{{future}}" class="code_future">
<text wx:if="{{dayDiff}}">{{dayDiff}}天</text>
<text wx:if="{{hourDiff}}">{{hourDiff}}时</text>
<text wx:if="{{minDiff}}">{{minDiff}}分</text>
<text>后可用</text>
</view> -->
</view>
<!-- <view class="couponBox">
<view class="an_title_text">使用流程</view>
<view class="step_wrapper">
<view class="step_box">
<image webp class="step_icon" src="../../../images/coupons/scrm_step_one.png" />
<view class="an_title_text">导航到店</view>
</view>
<image webp class="step_arrpw" src="../../../images/coupons/scrm_step_arrow.png" />
<view class="step_box">
<image webp class="step_icon" src="../../../images/coupons/scrm_step_two.png" />
<view class="an_title_text">开始服务</view>
</view>
<image webp class="step_arrpw" src="../../../images/coupons/scrm_step_arrow.png" />
<view class="step_box">
<image webp class="step_icon" src="../../../images/coupons/scrm_step_three.png" />
<view class="an_title_text">出示核销码</view>
</view>
</view>
<view class="desc_wrapper">{{detailInfo.useDescription || ''}}</view>
</view> -->
<view class="couponBox" style="margin-bottom: 0;">
<view class="couponBox-X" style="padding-bottom: 16rpx;">
<view class="titleDay">有效日期:</view>
<view wx:if="{{couponInfo.effectiveType==3 || coupon.effectiveType==3}}" class="titleDay_text darkColor">永久有效</view>
<view wx:if="{{couponInfo.effectiveType==2 || coupon.effectiveType==2}}" class="titleDay_text darkColor">{{detailInfo.receiveStartTime || coupon.receiveStartTime}}-{{detailInfo.receiveEndTime || coupon.receiveEndTime}}</view>
<view wx:if="{{couponInfo.effectiveType==1 || coupon.effectiveType==1}}" class="titleDay_text darkColor">有效期至{{detailInfo.receiveEndTime || coupon.receiveEndTime}}</view>
</view>
<view class="couponBox-X" style="padding-bottom: 16rpx;">
<view class="titleDay">获取日期:</view>
<view class="titleDay_text darkColor">{{detailInfo.receiveTime}}</view>
</view>
<view class="couponBox-X" style="line-height: 44rpx;">
<view class="titleDay">使用说明:</view>
<view class="titleDay_text darkColor" style="white-space:pre-wrap">{{detailInfo.useDescription || ''}}</view>
</view>
</view>
<view wx:if="{{detailInfo.list.length}}" class="couponBox">
<view class="an_title_text">使用记录</view>
<view wx:for="{{detailInfo.list}}" wx:key="index" class="note_line">
<view class="line_text_name">{{item.verificationMerchantName}}</view>
<view class="line_text">{{item.verificationTime}}</view>
<view class="line" wx:if="{{index < detailInfo.list.length - 1}}"></view>
</view>
</view>
</view>
</view>
<view class="box" wx:if="{{coupon.relatedGoodsId}}">
<view class="box-X">
<view class="title">关联商品</view>
<view class="goods">
<view class="icon">
<image webp src="{{coupon.relatedGoodsImage || ''}}"></image>
</view>
<view class="info">
<view>
<view class="name">{{coupon.relatedGoodsName || ''}}</view>
</view>
<view class="price">
¥<view class="price-X">{{coupon.relatedGoodsPrice || ''}}</view>
</view>
</view>
</view>
</view>
</view>
<view class="box" wx:if="{{detailInfo.suitMerchantLists && detailInfo.suitMerchantLists.length}}">
<view class="couponBox">
<view class="title">适用门店</view>
<view wx:for="{{detailInfo.suitMerchantLists}}" wx:key="index" class="store-box">
<view class="storeName">{{item.merchantName}}</view>
<view wx:if="{{item.bussinessBegintime}}" class="businessTime">营业时间:{{item.bussinessBegintime}}-{{item.bussinessEndtime}}</view>
<view wx:else class="businessTime">营业时间:无</view>
<view class="line" wx:if="{{item.merchantAddress}}"></view>
<view class="addressBox" wx:if="{{item.merchantAddress}}">
<view style="width: 552rpx;padding-right: 24rpx;">{{item.merchantAddress}}</view>
<view class="navigation" catchtap="jump" data-item="{{item}}">
<glsx-image webp src="mine/icon-go.png"></glsx-image>
</view>
</view>
</view>
</view>
</view>
</block>
\ No newline at end of file \ No newline at end of file
// index.js
// 获取应用实例
Page({
data: {
tabs: ['店铺优惠券', '权益优惠券'],
curTabIndex: 0,
couponsList: [],
imgBaseURL: 'https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/',
showGiftsModal: false,
giftsList: [],
haveCouponsList: []
},
jump(e) {
let {
item
} = e.currentTarget.dataset
// console.log(e)
let url = '/packageMine/pages/order/detail/detail'
wx.p.router.go(url, item)
},
state(e) {
let {
key
} = e.currentTarget.dataset
let {
couponsList,
haveCouponsList
} = this.data
couponsList[key].checkCoupon = !couponsList[key].checkCoupon
if (!couponsList[key].checkCoupon) {
couponsList[key].userCouponList = haveCouponsList[key].slice(0, 4)
} else {
couponsList[key].userCouponList = haveCouponsList[key]
}
this.setData({
couponsList
})
},
changeTab(e) {
let {
showLogin
} = this.data
if(showLogin) return
this.data.haveCouponsList = []
this.setData({
curTabIndex: e.detail,
couponsList: [],
flag: false
})
this.getCouponsList()
},
bottomToRefresh(e) {
let isBottom = e.detail.direction
if (isBottom == 'bottom') {
//刷新下一页
}
},
getCouponsList() {
wx.p.wxApi.showLoading('加载中...')
let {
curTabIndex,
isMerchant
} = this.data
let {merchantId} = wx.p.storage.get('merchant_info')
let para = {
useMemberType: 0
}
if (curTabIndex == 1) para.discountType = 8 //线上优惠券加上这个参数
if (!isMerchant) para.merchantId = merchantId
wx.p.api.couponsApi.getCardData(para).then(res => {
wx.hideLoading()
// console.log(res);
let list = res.map(item => {
item.checkCoupon = false
item.userCouponList.map((itm, index) => {
itm.receiveStartTime = new Date(itm.receiveStartTime).format('yyyy.MM.dd')
if (itm.effectiveType == 1) {
itm.receiveEndTime = new Date(itm.receiveEndTime).format('yyyy.MM.dd hh:mm:ss')
} else {
itm.receiveEndTime = new Date(itm.receiveEndTime).format('yyyy.MM.dd')
}
itm.discountIntensity = itm.discountIntensity / 100
return itm
})
this.data.haveCouponsList.push(item.userCouponList)
return item
})
list = res.map(item => {
if (item.userCouponList.length > 4 && curTabIndex != 1) {
item.userCouponList = item.userCouponList.slice(0, 4)
}
return item
})
this.setData({
couponsList: list,
haveCouponsList: this.data.haveCouponsList,
flag: true
})
})
},
async onLoad(options) {
console.log(options)
const showLogin = await wx.p.router.intercept(false)
this.setData({
showLogin
})
//判断只展示当前门店的
if (options.isMerchant == 1) {
this.setData({
isMerchant: true
})
}
if (options.pageFrom == 'directional') {
this.setData({
showGiftsModal: true,
giftsList: options.list
})
}
this.getCouponsList()
},
// ***********定向礼包相关内容***********
clickClose() {
this.setData({
showGiftsModal: false
})
},
goInvolidPage() {
wx.p.router.go('../usedDetail/usedDetail', {
isOnline: this.data.curTabIndex
})
},
// 去使用
toUseGifts(e) {
let {
item
} = e.currentTarget.dataset
let {
discountType,
useChannel,
id
} = item
if (discountType == 2 || discountType == 4) {
wx.p.router.go('/packageMall/pages/coupon/coupon', {
userCouponId: id,
useMemberType: item.useMemberType
})
return
}
/**线上商品代金券 */
if (discountType == 3 && useChannel == 1) {
if (item.useMemberType == 1) {
wx.p.wxApi.showToast('代金券已使用')
return
}
wx.p.router.go('/packageMine/pages/coupon/recommend/recommend', {
couponInfo: item
})
return
}
wx.p.router.go('/packageMine/pages/coupon/detail/detail', {
item
})
},
toUseConpon(e) {
const {
brandName,
goodsId,
id,
goodsLogo,
appearance,
goodsName,
couponId
} = e.currentTarget.dataset.item
let path = '/packageEquity/pages/commodity/detail/detail'
let param = {
supplier: 'HW',
brandName,
id: goodsId,
couponsId: id,
couponId
}
if (appearance == 2) {
path = '/packageEquity/pages/commodity/chargeDetail/chargeDetail'
param.productName = goodsName
param.icon = goodsLogo
}
wx.p.router.go(path, {
inType: 'game',
param
})
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {
"coupon-item": "../components/CouponsItem/element",
"tab":"/components/Tab/Tab"
},
"navigationBarTitleText": "我的卡券"
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/coupon/index/index.wxss */
/**index.wxss**/
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
page {
background: #F7F8FA;
}
.tab_widget {
width: 100%;
height: 92rpx;
background: #FFFFFF;
}
.tab_element {
width: 120rpx;
height: 92rpx;
position: relative;
color: #707071;
font-size: 36rpx;
display: flex;
align-items: center;
justify-content: center;
font-weight: 400;
}
.tab_element_active {
font-size: 40rpx;
color: #2D2D2E;
font-weight: 500;
}
.active_tab_line {
width: 48rpx;
height: 8rpx;
background: var(--btnColor);
border-radius: 2rpx;
position: absolute;
left: 50%;
bottom: 0;
transform: translate(-50%, 0);
}
.content_widget {
box-sizing: border-box;
/* padding: 0 32rpx; */
}
.box_wrapper {
width: 100%;
box-sizing: border-box;
padding: 20rpx;
display: flex;
align-items: center;
position: relative;
margin-top: 24rpx;
}
.left_icon_box {
width: 156rpx;
height: 156rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.left_bg {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 156rpx;
height: 156rpx;
z-index: 1;
}
.left_text_one {
font-size: 36rpx;
font-weight: 600;
color: #FFFFFF;
z-index: 2;
}
.left_text_two {
display: flex;
align-items: flex-end;
}
.left_text_three {
font-size: 20rpx;
margin-top: 6rpx;
}
.price_icon {
font-size: 20rpx;
margin-right: 4rpx;
}
.main_box {
height: 156rpx;
box-sizing: border-box;
padding: 4rpx 0 4rpx 20rpx;
}
.box_btn {
position: absolute;
right: 20rpx;
top: 50%;
transform: translate(0, -50%);
width: 120rpx;
height: 44rpx;
background: #B1B1B3;
border-radius: 22rpx;
color: #FFF;
font-size: 20rpx;
text-align: center;
line-height: 44rpx;
}
.title_text {
color: #282829;
font-weight: 600;
color: #282829;
font-size: 28rpx;
}
.h4_text {
font-weight: 400;
color: #B1B1B3;
font-size: 24rpx;
}
.drive {
margin-top: 38rpx;
}
.involid_btn{
display: flex;
justify-content: center;
}
.view_involid{
height: 48rpx;
line-height: 48rpx;
border: 2rpx solid #999999;
border-radius: 24rpx;
color: #999999;
width: 204rpx;
text-align: center;
/* display: flex;
align-items: center;
justify-content: center; */
}
.view_involid .text{
height: 48rpx;
line-height: 48rpx;
}
.view_involid .right{
width: 24rpx;
height: 24rpx;
vertical-align: middle;
}
.no_data {
padding-top: 48rpx;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 36rpx;
}
.nodata_bg {
width: 320rpx;
height: 320rpx;
}
.nodata_text {
color: #B1B1B3;
font-size: 28rpx;
line-height: 44rpx;
margin-top: 8rpx;
}
/* 定向礼包弹框 */
.flex_ccc {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.gifts_modal {
position: fixed;
left: 0;
right: 0;
top: 0;
right: 0;
background: rgba(0, 0, 0, 0.66);
width: 100%;
height: 100%;
z-index: 999999;
}
.gifts_wrap {
width: 100%;
height: 100%;
}
.gifts_wrapper {
width: 100%;
/* height: 337rpx; */
position: relative;
}
/*自定义背景颜色*/
.custom_banner_wrap{
width: 86%;
min-height: 170rpx;
/* background: linear-gradient(-180deg, #FE7534, #FF4815); */
position: absolute;
top:51.3%;
left: 50%;
transform: translateX(-50%);
z-index: -1;
/* border-radius:0 0 32rpx 32rpx; */
}
.custom_box{
height: 170rpx;
}
.gifts_modal_bg {
width: 87.3%;
height: 51.3%;
}
.gifts_modal_btn {
width: 39%;
height: 102rpx;
margin-top: 56rpx;
}
.gifts_content_wrap {
width: calc(87.3% - 52rpx);
height: 64%;
/* background: #FFFFFF; */
position: absolute;
left: 50%;
bottom: 6rpx;
transform: translate(-50%, 0);
overflow-x: hidden;
overflow-y: scroll;
}
.gifts_modal_bottom_bg {
position: absolute;
left: 50%;
bottom: 6rpx;
transform: translate(-50%, 0);
width: 83.2%;
height: 87rpx;
}
.gifts_item_wrap {
width: 100%;
height: 170rpx;
position: relative;
}
.gifts_item_bg {
width: 100%;
height: 170rpx;
}
.gifts_po_wrap {
position: absolute;
left: 0;
top: 0;
height: 170rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.left_widget {
box-sizing: border-box;
padding:0 0 0 40rpx;
width: 70%;
}
.coup_title{
font-size: 30rpx;
font-weight: 400;
color: #1A1919;
width: 70%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.coup_tip {
font-size: 24rpx;
font-weight: 400;
color: #817F7C;
margin-top: 19rpx;
}
.right_widget{
padding-right: 32rpx;
}
.gifts_to_use_bg{
width: 120rpx;
height: 46rpx;
}
/**小于2的样式*/
.mini_widget{
width: 100%;
min-height: 207rpx;
}
.mini_header_bg{
width: 87.3%;
height: 207rpx;
}
.mini_box_wrap{
width: 86.3%;
height: 281rpx;
position: relative;
box-sizing: border-box;
padding: 0 29rpx;
}
.mini_box_bg{
width: 100%;
height: 345rpx;
position: absolute;
top: -54rpx;
left: 0;
right: 0;
z-index: -1;
}
.storeName {
margin-top: 30rpx;
font-size: 32rpx;
font-weight: 500;
color: #282829;
/* display: inline-block; */
}
.storeWidth {
max-width: 477rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.stretch {
font-size: 32rpx;
font-weight: 500;
color: #999;
margin-left: 10rpx;
}
.stretchColor {
color: var(--btnColor);
font-size: 32rpx;
font-weight: 500;
margin-left: 10rpx;
}
/* .listWidth {
max-height: 810rpx;
overflow: hidden;
white-space: nowrap;
} */
.checkList {
justify-content: center;
margin-top: 18rpx;
}
.checkList .check {
font-size: 24rpx;
color: #999;
}
.state {
width: 24rpx;
height: 24rpx;
margin-left: 10rpx;
}
.associatedOrder {
display: flex;
font-size: 24rpx;
padding-top: 8rpx;
}
.associatedOrder .order {
color: #666;
}
.associatedOrder .order-X {
color: #333;
max-width: 337rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.associatedOrder .checkOrder {
color: var(--btnColor);
position: absolute;
right: 0;
}
.online_conpon_ctnr{
margin-top: 32rpx;
}
.online_conpon{
height: 156rpx;
background: #FFF5F3;
border-radius: 8rpx;
padding: 8rpx;
display: flex;
}
.online_conpon .price_wrap{
padding-left: 16rpx;
display: flex;
flex-direction: column;
justify-content: center;
width: 154rpx;
flex-shrink: 0;
color: var(--btnColor);
}
.price_wrap .num{
height: 84rpx;
font-weight: 600;
font-size: 42rpx;
color: var(--btnColor);
}
.price_wrap .unit{
height: 28rpx;
font-weight: 500;
font-size: 20rpx;
color: var(--btnColor);
vertical-align: text-top;
margin-left: 4rpx;
}
.price_wrap .tip{
height: 34rpx;
font-weight: 400;
font-size: 24rpx;
color: #D83C14;
}
.online_conpon .info_wrap{
flex: 1;
background-color: #fff;
padding: 16rpx 12rpx 16rpx 24rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
position: relative;
}
.info_wrap .name{
height: 80rpx;
font-weight: 600;
font-size: 28rpx;
color: #333333;
line-height: 40rpx;
}
.info_wrap .remark,.info_wrap .date{
height: 28rpx;
line-height: 20rpx;
font-weight: 400;
font-size: 20rpx;
color: #D83C14;
}
.info_wrap .use_btn{
position: absolute;
width: 136rpx;
height: 48rpx;
line-height: 48rpx;
background-image: linear-gradient(90deg, var(--btnColor) 2%, #FF1A33 96%);
border-radius: 23rpx;
color: #fff;
text-align: center;
right: 12rpx;
bottom: 16rpx;
}
.isFullSucreen-btn{
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
\ No newline at end of file \ No newline at end of file
<view class="coupons_container">
<view class="tab_widget">
<tab tab="{{tabs}}" bindclick="changeTab"></tab>
</view>
<block wx:if="{{showLogin}}">
<view class="no_data">
<glsx-image webp class="nodata_bg" src="coupons/no_card_bg.png" />
<view class="nodata_text">暂无优惠券</view>
</view>
</block>
<block wx:else>
<block wx:if="{{flag}}">
<view wx:if="{{couponsList.length}}" style="height:-116rpx;padding-bottom: 35rpx;" class="content_widget">
<scroll-view scroll-y="{{true}}" style="height:100%;padding: 0 32rpx;box-sizing: border-box;" class="scroll_wrap" bindscrolltolower="bottomToRefresh">
<!-- listWidth -->
<view wx:for="{{couponsList}}" wx:key="index">
<block wx:if="{{curTabIndex == 0}}">
<view class="flex storeName">
<text class="storeWidth">{{item.merchantName}}</text>
<text class="{{curTabIndex == 0 ? 'stretchColor':'stretch'}}">({{item.couponAmount}}张)</text>
</view>
<block wx:for="{{item.userCouponList}}" wx:for-item="i" wx:key="id">
<coupon-item btnStatus="{{curTabIndex}}" coupons="{{i}}" useMemberType="{{curTabIndex}}"></coupon-item>
<view class="associatedOrder" wx:if="{{i.goodsOrderCode && curTabIndex == 1}}">
<view class="order">该券已用在订单:</view>
<view class="order-X" catchtap="jump" data-item="{{i.goodsOrderCode}}">{{i.goodsName}}</view>
<view class="checkOrder" catchtap="jump" data-item="{{i.goodsOrderCode}}">查看订单></view>
</view>
</block>
<block wx:if="{{haveCouponsList[index].length > 4}}">
<view class="flex checkList" wx:if="{{!item.checkCoupon}}" catchtap="state" data-key="{{index}}">
<view class="check">查看剩余所有券</view>
<glsx-image webp class="state" src="mine/coupon/down.png" />
</view>
<view class="flex checkList" wx:else catchtap="state" data-key="{{index}}">
<view class="check">收起</view>
<glsx-image webp class="state" src="mine/coupon/up.png" />
</view>
</block>
</block>
<block wx:else>
<view class="online_conpon_ctnr" wx:for="{{item.userCouponList}}" wx:for-item="i" wx:key="id">
<view class="online_conpon">
<view class="price_wrap">
<view>
<text class="num">{{i.denomination || 0}}</text>
<text class="unit">元</text>
</view>
<view class="tip">无门槛</view>
</view>
<view class="info_wrap">
<view class="name">{{i.brandName ? i.brandName + '·' : ''}}{{i.appearance == 2 ? i.goodsName + i.rechargeDenomination : i.goodsName}}</view>
<!-- <view class="remark">无门槛</view> -->
<view class="date" wx:if="{{i.discountType == 8}}">数量:{{i.amount}}</view>
<view class="date" wx:if="{{i.discountType != 8}}">有效期{{i.effectiveDays || 0}}天</view>
<view class="date" wx:else>剩余有效期:{{i.residueEffectiveDays || 0}}天</view>
<view class="use_btn" bindtap="toUseConpon" data-item="{{i}}">去使用</view>
</view>
</view>
</view>
</block>
</view>
</scroll-view>
</view>
<view wx:else class="no_data">
<glsx-image webp class="nodata_bg" src="coupons/no_card_bg.png" />
<view class="nodata_text">暂无优惠券</view>
</view>
<view class="involid_btn isFullSucreen-btn">
<view class="view_involid" bindtap="goInvolidPage">
<text class="text">查看失效券</text>
<glsx-image class="right" src="mine/right.png"></glsx-image>
</view>
</view>
</block>
<!-- 定向礼包弹框 -->
<view wx:if="{{showGiftsModal}}" class="gifts_modal flex_ccc">
<view class="gifts_wrap flex_ccc">
<view wx:if="{{giftsList.length>2}}" class="gifts_wrapper flex_ccc">
<glsx-image webp mode="widthFix" class="gifts_modal_bg" src="{{imgBaseURL}}gifts_list_bg.png" />
<view class="gifts_content_wrap">
<view wx:for="{{giftsList}}" class="gifts_item_wrap">
<glsx-image webp mode="widthFix" class="gifts_item_bg" src="{{imgBaseURL}}gifts_coupons_bg.png" />
<view class="gifts_po_wrap">
<view class="left_widget">
<view class="coup_title">{{item.couponName}}</view>
<view wx:if="{{item.effectiveType==3}}" class="coup_tip">无限期</view>
<view wx:if="{{item.effectiveType==2}}" class="coup_tip">有效期:{{item.receiveStartTime}}-{{item.receiveEndTime}}</view>
<view wx:if="{{item.effectiveType==1}}" class="coup_tip">有效至{{item.receiveEndTime}}</view>
</view>
<view class="right_widget">
<glsx-image webp mode="widthFix" bind:tap="toUseGifts" data-item="{{item}}" class="gifts_to_use_bg" src="{{imgBaseURL}}gifts_touse.png" />
</view>
</view>
</view>
<view style="height:88rpx"></view>
</view>
<glsx-image webp mode="widthFix" class="gifts_modal_bottom_bg" src="{{imgBaseURL}}gifts_fixed_bottom.png" />
</view>
<view wx:if="{{giftsList.length<3}}" class="mini_widget flex_ccc">
<glsx-image webp mode="widthFix" class="mini_header_bg" src="{{imgBaseURL}}gifts_header_bg.png" />
<view class="mini_box_wrap" style="height:{{giftsList.length==2?408:298}}rpx">
<glsx-image webp class="mini_box_bg" style="height:{{giftsList.length==2?450:340}}rpx" src="{{imgBaseURL}}gifts_box_bg.png" />
<view style="height:50rpx"></view>
<view wx:for="{{giftsList}}" class="gifts_item_wrap">
<glsx-image webp mode="widthFix" class="gifts_item_bg" src="{{imgBaseURL}}gifts_coupons_bg.png" />
<view class="gifts_po_wrap">
<view class="left_widget">
<view class="coup_title">{{item.couponName}}</view>
<view wx:if="{{item.effectiveType==3}}" class="coup_tip">无限期</view>
<view wx:if="{{item.effectiveType==2}}" class="coup_tip">有效期:{{item.receiveStartTime}}-{{item.receiveEndTime}}</view>
<view wx:if="{{item.effectiveType==1}}" class="coup_tip">有效至{{item.receiveEndTime}}</view>
</view>
<view class="right_widget">
<glsx-image webp mode="widthFix" bind:tap="toUseGifts" data-item="{{item}}" class="gifts_to_use_bg" src="{{imgBaseURL}}gifts_touse.png" />
</view>
</view>
</view>
</view>
</view>
<glsx-image webp mode="widthFix" bind:tap="clickClose" class="gifts_modal_btn" src="{{imgBaseURL}}gifts_comfirm_btn.png" />
</view>
</view>
</block>
</view>
\ No newline at end of file \ No newline at end of file
// packageMine/pages/coupon/recommend/recommend.js
Page({
/**
* 页面的初始数据
*/
data: {
list: [],
pageNum: 1,
detailInfo: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.id){
// 领取记录id 优惠券id 门店id
this.setData({
couponInfo: { merchantId:options.merchantId,couponId:options.couponId }
},()=>{
this.getDetailData(options.id)
})
return
}
this.setData(options, () => {
this.getDetailData(options.couponInfo.id)
})
},
jump(e) {
let { item } = e.currentTarget.dataset
wx.openLocation({
latitude: item.lat,
longitude: item.lng,
name: item.merchantName,
address: item.merchantAddress
})
},
jumpCommodity(e) {
let { item } = e.currentTarget.dataset
// console.log('item',item);
let { id } = item
let isActivity = false
if (this.data.couponInfo.merchantId == this.data.userInfo.merchantId) {
wx.p.router.go('/packageMall/pages/detail/detail', { id, isActivity, notIntercept: true })
} else {
wx.p.wxApi.showToast('其他门店商品,暂不支持查看')
}
},
getDetailData(id) {
let para = {
userCouponId: id
}
wx.p.wxApi.showLoading('加载中...')
wx.p.api.couponsApi.couponsDetail(para).then(res => {
res.receiveEndTime = new Date(res.receiveEndTime).format('yyyy.MM.dd hh:mm:ss')
res.receiveStartTime = new Date(res.receiveStartTime).format('yyyy.MM.dd hh:mm:ss')
res.receiveTime = new Date(res.receiveTime).format('yyyy.MM.dd hh:mm:ss')
this.setData(
{
detailInfo: res,
flag: true
},
() => {
this.getCouponGoodsPage()
}
)
})
},
getCouponGoodsPage() {
// wx.p.wxApi.showLoading()
let total = 0
let {
list,
pageNum,
couponInfo: { merchantId },
couponInfo: { couponId, id }
} = this.data
wx.p.api.shopmallApi
.getCouponGoodsPage({
pageNum,
couponId: couponId || id,
merchantId
})
.then(data => {
console.log(data)
this.setData({
list: [...list, ...data.list],
total,
listFlag: true
})
wx.hideLoading()
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
let { pageNum, total } = this.data
wx.p.wxApi.onReachBottom(
{
pageNum,
total
},
() => {
this.getCouponGoodsPage()
}
)
}
})
{
"navigationBarTitleText": "卡券详情",
"usingComponents": {
"coupon-item": "../components/CouponsItem/element"
}
}
/* packageMine/pages/coupon/recommend/recommend.wxss */
page {
background-color: #F7F8FA !important;
}
.layout{
padding-top: 24rpx;
padding-bottom: 24rpx;
}
.coupon {
height: 203rpx;
/* background: rgba(252, 91, 50, 0.05); */
/* border-radius: 8rpx; */
margin: 0 24rpx;
position: relative;
}
.coupon .bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.coupon .info {
position: relative;
z-index: 2;
display: flex;
width: 100%;
height: 100%;
}
.tips {
font-size: 28rpx;
color: #b1b1b3;
text-align: center;
margin: 32rpx 0 20rpx;
}
.goods-box{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 0 32rpx ;
}
.goods{
width: 328rpx;
height: 520rpx;
margin-bottom: 32rpx;
position: relative;
}
.coupon .left_box {
width: 255rpx;
height: 150rpx;
color: #FFFFFF;
font-size: 56rpx;
font-weight: 600;
text-align: center;
line-height: 150rpx;
}
.coupon .left_box .price_icon {
font-size: 24rpx;
font-weight: 500;
}
.coupon .right_box {
padding: 28rpx 28rpx 0 28rpx;
width: 464rpx;
}
.top_box {
height: 120rpx;
border-bottom: 2rpx dashed rgba(216, 60, 20, 0.1);
}
.top_box .voucherName {
font-size: 28rpx;
font-weight: 600;
padding-bottom: 8rpx;
}
.h4_text {
font-size: 20rpx;
font-weight: 400;
}
.brightColor {
color: var(--btnColor);
}
.darkColor {
color: #666;
}
.describeColor {
color: #D83C14;
}
.timeColor {
color: #999;
}
.bottom_box {
height: 42rpx;
line-height: 42rpx;
}
.box {
border-radius: 8rpx;
background-color: #fff;
padding: 32rpx 32rpx 20rpx 32rpx;
margin: 20rpx 32rpx 0;
box-shadow: 0rpx 8rpx 16rpx 0rpx rgba(224, 224, 224, 0.5);
}
.box .title {
font-size: 32rpx;
font-weight: 500;
padding-bottom: 24rpx;
color: #333;
}
.box .good {
display: flex;
padding-bottom: 12rpx;
}
.box .good .icon {
width: 144rpx;
height: 144rpx;
}
.box .good .icon image {
border-radius: 8rpx;
}
.box .lines {
height: 2rpx;
background: #EFF0F2;
margin: 20rpx 0 32rpx 0;
}
.box .good .info {
margin-left: 32rpx;
}
.box .good .info .name {
font-size: 28rpx;
color: #282829;
}
.box .good .info .price {
display: flex;
margin-top: 50rpx;
font-size: 36rpx;
font-weight: 600;
color: var(--btnColor);
}
.box .good .info .price .price-X {
margin-left: 10rpx;
}
.box .store-box {
background: #F9F9F9;
border: 2rpx solid #E9E9E9;
border-radius: 8rpx;
padding: 16rpx 32rpx;
margin-bottom: 18rpx;
}
.box .store-box:last-child {
margin-bottom: 0;
}
.box .storeName {
font-size: 28rpx;
color: #333;
margin-top: -4rpx;
}
.box .businessTime {
font-size: 24rpx;
color: #999;
margin-top: 4rpx;
padding-bottom: 18rpx;
}
.box .line {
height: 2rpx;
background: #EEE;
}
.box .addressBox {
padding-top: 20rpx;
font-size: 24rpx;
color: #666;
display: flex;
align-items: center;
}
.box .addressBox .navigation {
width: 32rpx;
height: 32rpx;
}
.box .box-X {
max-width: 610rpx;
line-height: 48rpx;
}
.box .box-X .titleDay {
font-size: 28rpx;
font-weight: 500;
color: #333;
}
.box .box-X .titleDay_text {
font-size: 24rpx;
color: #666;
}
\ No newline at end of file \ No newline at end of file
<block wx:if="{{flag}}">
<view class="layout">
<!-- <view class="coupon" style="background-image: url({{detailInfo.useMemberType == 0 ? onlineCouponBaseList[0]:onlineCouponBaseList[1]}});"> -->
<!-- <coupon-item coupons="{{couponInfo}}" hideBtn couponStyle="background:transparent"></coupon-item> -->
<view class="coupon">
<glsx-image webp src="mine/coupon/daijin{{detailInfo.useMemberType == 0 == 1?'':'-lose'}}.png" class="bg"></glsx-image>
<view class="info">
<view class="left_box">
<text class="price_icon">¥</text>
<text>{{detailInfo.denomination / 100}}</text>
</view>
<view class="right_box">
<view class="top_box">
<view class="voucherName {{detailInfo.useMemberType == 0 ? 'brightColor':''}}">{{couponInfo.couponName}}</view>
<view wx:if="{{(couponInfo.useBarriers==1 && couponInfo.discountType!=4) || (detailInfo.useBarriers==1 && detailInfo.discountType!=4)}}" class="h4_text {{detailInfo.useMemberType == 0 ? 'describeColor':'darkColor'}}">无门槛</view>
<view wx:if="{{(couponInfo.useBarriers==2 && couponInfo.discountType!=4) || (detailInfo.useBarriers==2 && detailInfo.discountType!=4)}}" class="h4_text {{detailInfo.useMemberType == 0 ? 'describeColor':'darkColor'}}">满{{detailInfo.full / 100}}元可用</view>
</view>
<view class="bottom_box">
<view wx:if="{{couponInfo.effectiveType==3 || detailInfo.effectiveType==3}}" class="h4_text timeColor">永久有效</view>
<view wx:if="{{couponInfo.effectiveType==2 || detailInfo.effectiveType==2}}" class="h4_text timeColor">{{detailInfo.receiveStartTime}}-{{detailInfo.receiveEndTime}}</view>
<view wx:if="{{couponInfo.effectiveType==1 || detailInfo.effectiveType==1}}" class="h4_text timeColor">有效期至{{detailInfo.receiveEndTime}}</view>
</view>
</view>
</view>
</view>
<view class="box" style="padding-bottom: 32rpx;">
<view class="box-X" style="padding-bottom: 16rpx;">
<view class="titleDay">有效日期:</view>
<view wx:if="{{couponInfo.effectiveType==3 || detailInfo.effectiveType==3}}" class="titleDay_text darkColor">永久有效</view>
<view wx:if="{{couponInfo.effectiveType==2 || detailInfo.effectiveType==2}}" class="titleDay_text darkColor">{{detailInfo.receiveStartTime}}-{{detailInfo.receiveEndTime}}</view>
<view wx:if="{{couponInfo.effectiveType==1 || detailInfo.effectiveType==1}}" class="titleDay_text darkColor">有效期至{{detailInfo.receiveEndTime}}</view>
</view>
<view class="box-X" style="padding-bottom: 16rpx;">
<view class="titleDay">获取日期:</view>
<view class="titleDay_text darkColor">{{detailInfo.receiveTime}}</view>
</view>
<view class="box-X" style="line-height: 44rpx;">
<view class="titleDay">使用说明:</view>
<view class="titleDay_text darkColor" style="white-space:pre-wrap">{{detailInfo.useDescription || ''}}</view>
</view>
</view>
<view class="box" wx:if="{{list.length}}">
<view class="title">适用商品</view>
<block wx:for="{{list}}" wx:key="index">
<view class="good" catchtap="jumpCommodity" data-item="{{item}}">
<view class="icon">
<image webp src="{{item.goodsImage}}"></image>
</view>
<view class="info">
<view class="name">{{item.goodsName}}</view>
<view class="price">
¥<view class="price-X">{{item.retailPrice / 100}}</view>
</view>
</view>
</view>
<view class="lines" wx:if="{{index < list.length - 1}}"></view>
</block>
</view>
<view class="box" style="margin-bottom: 32rpx;" wx:if="{{detailInfo.suitMerchantLists && detailInfo.suitMerchantLists.length}}">
<view class="title">适用门店</view>
<view wx:for="{{detailInfo.suitMerchantLists}}" wx:key="index" class="store-box">
<view class="storeName">{{item.merchantName}}</view>
<view wx:if="{{item.bussinessBegintime}}" class="businessTime">营业时间:{{item.bussinessBegintime}}-{{item.bussinessEndtime}}</view>
<view wx:else class="businessTime">营业时间:无</view>
<view class="line" wx:if="{{item.merchantAddress}}"></view>
<view class="addressBox" wx:if="{{item.merchantAddress}}">
<view style="width: 552rpx;padding-right: 24rpx;">{{item.merchantAddress}}</view>
<view class="navigation" catchtap="jump" data-item="{{item}}">
<glsx-image webp src="mine/icon-go.png"></glsx-image>
</view>
</view>
</view>
</view>
<!-- <view class="tips">- 为你推荐 -</view>
<view class="goods-box">
<block wx:if="{{listFlag}}">
<block wx:if="{{list.length}}">
<block wx:for="{{list}}" wx:key="index">
<view class="goods">
<goods item="{{item}}"></goods>
</view>
</block>
<block wx:if="{{nothing}}">
<view class="list-nothing ">到底啦!!</view>
</block>
</block>
<block wx:else>
<view class="list-nothing">
暂无可使用商品
</view>
</block>
</block>
</view> -->
</view>
</block>
\ No newline at end of file \ No newline at end of file
Page({
data: {
count: 5
},
countDown() {
let count = this.data.count
this.data.countDownTime = setInterval(() => {
if (count == 0) {
clearInterval(this.data.countDownTime);
this.goToIndex()
return;
}
count--;
this.setData({
count
})
}, 1 * 1000);
},
goToIndex() {
wx.p.router.switchTab('/pages/tab/index/index')
},
goToCoupons() {
clearInterval(this.data.countDownTime);
wx.p.router.redirectTo('/packageMine/pages/coupon/index/index')
},
onUnload() {
clearInterval(this.data.countDownTime);
},
onLoad() {
this.countDown()
}
})
\ No newline at end of file \ No newline at end of file
{
"navigationBarTitleText": "领取成功"
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/coupon/success/success.wxss */
\ No newline at end of file \ No newline at end of file
<view class="success_page">
<!-- <image webp class="success_icon" src="../../../../images/coupons/success.png" /> -->
<image webp class="success_icon" src="{{IMGURL}}coupons/success.png?v={{img_version}}" />
<view class="success_text">您的优惠礼券领取成功!</view>
<view class="success_count">{{count}}秒后自动跳转到首页</view>
<view class="success_btn_wrap btn_pos">
<view class="btn_box btn_orage" bind:tap="goToCoupons">使用优惠券</view>
</view>
<view class="success_btn_wrap">
<view bind:tap="goToIndex" class="btn_box">回到首页</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
page {
background: #F7F8FA;
}
.success_page {
display: flex;
flex-direction: column;
align-items: center;
}
.success_icon {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
margin-top: 112rpx;
}
.success_text {
font-weight: 500;
color: #282829;
font-size: 32rpx;
margin-top: 84rpx;
}
.success_count {
font-weight: 400;
color: #B1B1B3;
font-size: 28rpx;
margin-top: 20rpx;
}
.success_btn_wrap {
position: fixed;
bottom: 270rpx;
left: 0;
right: 0;
box-sizing: border-box;
padding: 0 32rpx;
}
.btn_box {
width: 100%;
height: 88rpx;
text-align: center;
line-height: 88rpx;
color: #B1B1B3;
font-size: 32rpx;
border-radius: 8rpx;
border: 2rpx solid #B1B1B3;
}
.btn_orage {
background: var(--btnColor);
border: 2rpx solid var(--btnColor);
color: #FFFFFF;
}
.btn_pos {
bottom: 390rpx;
}
\ No newline at end of file \ No newline at end of file
// index.js
// 获取应用实例
Page({
data: {
tabs: ['已使用', '已失效'],
curTabIndex: 0,
couponsList: [],
imgBaseURL: 'https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/',
showGiftsModal: false,
giftsList: [],
haveCouponsList: []
},
jump(e) {
let {
item
} = e.currentTarget.dataset
// console.log(e)
let url = '/packageMine/pages/order/detail/detail'
// if (orderStatus > 5 && orderStatus != 14 && orderStatus != 13&&orderStatus != 15) url = 'afterSaleDetail'
wx.p.router.go(url, item)
// wx.navigateTo({
// url: '/packageMine/pages/order/detail/detail?orderCode=S2112081509592138'
// })
},
state(e) {
let {
key
} = e.currentTarget.dataset
let {
couponsList,
haveCouponsList
} = this.data
couponsList[key].checkCoupon = !couponsList[key].checkCoupon
if (!couponsList[key].checkCoupon) {
couponsList[key].userCouponList = haveCouponsList[key].slice(0, 4)
} else {
couponsList[key].userCouponList = haveCouponsList[key]
}
this.setData({
couponsList
})
},
changeTab(e) {
this.data.haveCouponsList = []
this.setData({
curTabIndex: e.detail,
couponsList: [],
flag: false
})
this.getCouponList()
},
bottomToRefresh(e) {
let isBottom = e.detail.direction
if (isBottom == 'bottom') {
//刷新下一页
}
},
getCouponList() {
wx.p.wxApi.showLoading('加载中...')
let {
curTabIndex,
isMerchant,
isOnline
} = this.data
let {
merchantId
} = wx.p.storage.get('merchant_info')
let para = {
useMemberType: curTabIndex + 1
}
if (isOnline == 1) para.discountType = 8 //线上优惠券加上这个参数
if (!isMerchant) para.merchantId = merchantId
wx.p.api.couponsApi.getCardData(para).then(res => {
wx.hideLoading()
// console.log(res);
let list = res.map(item => {
item.checkCoupon = false
item.userCouponList.map((itm, index) => {
itm.receiveStartTime = new Date(itm.receiveStartTime).format('yyyy.MM.dd')
if (itm.effectiveType == 1) {
itm.receiveEndTime = new Date(itm.receiveEndTime).format('yyyy.MM.dd hh:mm:ss')
} else {
itm.receiveEndTime = new Date(itm.receiveEndTime).format('yyyy.MM.dd')
}
itm.discountIntensity = itm.discountIntensity / 100
return itm
})
this.data.haveCouponsList.push(item.userCouponList)
return item
})
list = res.map(item => {
if (item.userCouponList.length > 4 && isOnline != 1) {
item.userCouponList = item.userCouponList.slice(0, 4)
}
return item
})
this.setData({
couponsList: list,
haveCouponsList: this.data.haveCouponsList,
flag: true
})
})
},
onLoad(options) {
if (options.pageFrom == 'directional') {
this.setData({
showGiftsModal: true,
giftsList: options.list
})
}
this.setData({
isMerchant: true,
isOnline: options.isOnline
})
//判断只展示当前门店的
// if (isMerchant == 1) {
// this.setData({
// isMerchant: true
// })
// }
this.getCouponList()
},
// ***********定向礼包相关内容***********
clickClose() {
this.setData({
showGiftsModal: false
})
},
// 去使用
toUseGifts(e) {
let {
item
} = e.currentTarget.dataset
let {
discountType,
useChannel,
id
} = item
if (discountType == 2 || discountType == 4) {
wx.p.router.go('/packageMall/pages/coupon/coupon', {
userCouponId: id,
useMemberType: item.useMemberType
})
return
}
/**线上商品代金券 */
if (discountType == 3 && useChannel == 1) {
if (item.useMemberType == 1) {
wx.p.wxApi.showToast('代金券已使用')
return
}
wx.p.router.go('/packageMine/pages/coupon/recommend/recommend', {
couponInfo: item
})
return
}
wx.p.router.go('/packageMine/pages/coupon/detail/detail', {
item
})
wx.navigateTo({
url: '/?item=' + temp
})
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {
"coupon-item": "../components/CouponsItem/element",
"tab":"/components/Tab/Tab"
},
"navigationBarTitleText": "我的卡券"
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/coupon/index/index.wxss */
/**index.wxss**/
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
page {
background: #F7F8FA;
}
.tab_widget {
width: 100%;
height: 92rpx;
background: #FFFFFF;
}
.tab_element {
width: 120rpx;
height: 92rpx;
position: relative;
color: #707071;
font-size: 36rpx;
display: flex;
align-items: center;
justify-content: center;
font-weight: 400;
}
.tab_element_active {
font-size: 40rpx;
color: #2D2D2E;
font-weight: 500;
}
.active_tab_line {
width: 48rpx;
height: 8rpx;
background: var(--btnColor);
border-radius: 2rpx;
position: absolute;
left: 50%;
bottom: 0;
transform: translate(-50%, 0);
}
.content_widget {
box-sizing: border-box;
/* padding: 0 32rpx; */
}
.box_wrapper {
width: 100%;
box-sizing: border-box;
padding: 20rpx;
display: flex;
align-items: center;
position: relative;
margin-top: 24rpx;
}
.left_icon_box {
width: 156rpx;
height: 156rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.left_bg {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 156rpx;
height: 156rpx;
z-index: 1;
}
.left_text_one {
font-size: 36rpx;
font-weight: 600;
color: #FFFFFF;
z-index: 2;
}
.left_text_two {
display: flex;
align-items: flex-end;
}
.left_text_three {
font-size: 20rpx;
margin-top: 6rpx;
}
.price_icon {
font-size: 20rpx;
margin-right: 4rpx;
}
.main_box {
height: 156rpx;
box-sizing: border-box;
padding: 4rpx 0 4rpx 20rpx;
}
.box_btn {
position: absolute;
right: 20rpx;
top: 50%;
transform: translate(0, -50%);
width: 120rpx;
height: 44rpx;
background: #B1B1B3;
border-radius: 22rpx;
color: #FFF;
font-size: 20rpx;
text-align: center;
line-height: 44rpx;
}
.title_text {
color: #282829;
font-weight: 600;
color: #282829;
font-size: 28rpx;
}
.h4_text {
font-weight: 400;
color: #B1B1B3;
font-size: 24rpx;
}
.drive {
margin-top: 38rpx;
}
.involid_btn{
display: flex;
justify-content: center;
margin-top: 36rpx;
}
.view_involid{
height: 48rpx;
line-height: 48rpx;
border: 2rpx solid #999999;
border-radius: 24rpx;
color: #999999;
width: 204rpx;
text-align: center;
}
.no_data {
padding-top: 48rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.nodata_bg {
width: 320rpx;
height: 320rpx;
}
.nodata_text {
color: #B1B1B3;
font-size: 28rpx;
line-height: 44rpx;
margin-top: 8rpx;
}
/* 定向礼包弹框 */
.flex_ccc {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.gifts_modal {
position: fixed;
left: 0;
right: 0;
top: 0;
right: 0;
background: rgba(0, 0, 0, 0.66);
width: 100%;
height: 100%;
z-index: 999999;
}
.gifts_wrap {
width: 100%;
height: 100%;
}
.gifts_wrapper {
width: 100%;
/* height: 337rpx; */
position: relative;
}
/*自定义背景颜色*/
.custom_banner_wrap{
width: 86%;
min-height: 170rpx;
/* background: linear-gradient(-180deg, #FE7534, #FF4815); */
position: absolute;
top:51.3%;
left: 50%;
transform: translateX(-50%);
z-index: -1;
/* border-radius:0 0 32rpx 32rpx; */
}
.custom_box{
height: 170rpx;
}
.gifts_modal_bg {
width: 87.3%;
height: 51.3%;
}
.gifts_modal_btn {
width: 39%;
height: 102rpx;
margin-top: 56rpx;
}
.gifts_content_wrap {
width: calc(87.3% - 52rpx);
height: 64%;
/* background: #FFFFFF; */
position: absolute;
left: 50%;
bottom: 6rpx;
transform: translate(-50%, 0);
overflow-x: hidden;
overflow-y: scroll;
}
.gifts_modal_bottom_bg {
position: absolute;
left: 50%;
bottom: 6rpx;
transform: translate(-50%, 0);
width: 83.2%;
height: 87rpx;
}
.gifts_item_wrap {
width: 100%;
height: 170rpx;
position: relative;
}
.gifts_item_bg {
width: 100%;
height: 170rpx;
}
.gifts_po_wrap {
position: absolute;
left: 0;
top: 0;
height: 170rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.left_widget {
box-sizing: border-box;
padding:0 0 0 40rpx;
width: 70%;
}
.coup_title{
font-size: 30rpx;
font-weight: 400;
color: #1A1919;
width: 70%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.coup_tip {
font-size: 24rpx;
font-weight: 400;
color: #817F7C;
margin-top: 19rpx;
}
.right_widget{
padding-right: 32rpx;
}
.gifts_to_use_bg{
width: 120rpx;
height: 46rpx;
}
/**小于2的样式*/
.mini_widget{
width: 100%;
min-height: 207rpx;
}
.mini_header_bg{
width: 87.3%;
height: 207rpx;
}
.mini_box_wrap{
width: 86.3%;
height: 281rpx;
position: relative;
box-sizing: border-box;
padding: 0 29rpx;
}
.mini_box_bg{
width: 100%;
height: 345rpx;
position: absolute;
top: -54rpx;
left: 0;
right: 0;
z-index: -1;
}
.storeName {
margin-top: 30rpx;
font-size: 32rpx;
font-weight: 500;
color: #282829;
/* display: inline-block; */
}
.storeWidth {
max-width: 477rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.stretch {
font-size: 32rpx;
font-weight: 500;
color: #999;
margin-left: 10rpx;
}
.stretchColor {
color: var(--btnColor);
font-size: 32rpx;
font-weight: 500;
margin-left: 10rpx;
}
/* .listWidth {
max-height: 810rpx;
overflow: hidden;
white-space: nowrap;
} */
.checkList {
justify-content: center;
margin-top: 18rpx;
}
.checkList .check {
font-size: 24rpx;
color: #999;
}
.state {
width: 24rpx;
height: 24rpx;
margin-left: 10rpx;
}
.associatedOrder {
display: flex;
font-size: 24rpx;
padding-top: 8rpx;
}
.associatedOrder .order {
color: #666;
}
.associatedOrder .order-X {
color: #333;
max-width: 337rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.associatedOrder .checkOrder {
color: var(--btnColor);
position: absolute;
right: 0;
}
.online_conpon_ctnr{
margin-top: 32rpx;
}
.online_conpon{
height: 156rpx;
background: #F1F1F1;
border-radius: 8rpx;
padding: 8rpx;
display: flex;
}
.online_conpon .price_wrap{
padding-left: 16rpx;
display: flex;
flex-direction: column;
justify-content: center;
width: 154rpx;
flex-shrink: 0;
color: var(--btnColor);
}
.price_wrap .num{
height: 84rpx;
font-weight: 600;
font-size: 42rpx;
color: #6D6D6D;
}
.price_wrap .unit{
height: 28rpx;
font-weight: 500;
font-size: 20rpx;
color: #6D6D6D;
vertical-align: text-top;
margin-left: 4rpx;
}
.price_wrap .tip{
height: 34rpx;
font-weight: 400;
font-size: 24rpx;
color: #6D6D6D;
}
.online_conpon .info_wrap{
flex: 1;
background-color: #fff;
padding: 16rpx 12rpx 16rpx 24rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
position: relative;
}
.info_wrap .name{
height: 80rpx;
font-weight: 600;
font-size: 28rpx;
color: #333333;
line-height: 40rpx;
}
.info_wrap .remark,.info_wrap .date{
height: 28rpx;
line-height: 20rpx;
font-weight: 400;
font-size: 20rpx;
color: #6D6D6D;
}
.info_wrap .use_btn{
position: absolute;
width: 136rpx;
height: 48rpx;
line-height: 48rpx;
background-color: #B0B0B0;
border-radius: 23rpx;
color: #fff;
text-align: center;
right: 12rpx;
bottom: 16rpx;
}
\ No newline at end of file \ No newline at end of file
<view class="coupons_container">
<view class="tab_widget">
<tab tab="{{tabs}}" bindclick="changeTab"></tab>
</view>
<block wx:if="{{flag}}">
<view wx:if="{{couponsList.length}}" style="height:-116rpx;padding-bottom: 35rpx;" class="content_widget">
<scroll-view scroll-y="{{true}}" style="height:100%;padding: 0 32rpx;box-sizing: border-box;" class="scroll_wrap" bindscrolltolower="bottomToRefresh">
<!-- listWidth -->
<view wx:for="{{couponsList}}" wx:key="index">
<block wx:if="{{isOnline!=1}}">
<view class="flex storeName">
<text class="storeWidth">{{item.merchantName}}</text>
<text class="'stretch'">({{item.couponAmount}}张)</text>
</view>
<block wx:for="{{item.userCouponList}}" wx:for-item="i" wx:key="id">
<coupon-item btnStatus="{{curTabIndex+1}}" coupons="{{i}}" useMemberType="{{curTabIndex+1}}"></coupon-item>
<view class="associatedOrder" wx:if="{{i.goodsOrderCode && curTabIndex == 0}}">
<view class="order">该券已用在订单:</view>
<view class="order-X" catchtap="jump" data-item="{{i.goodsOrderCode}}">{{i.goodsName}}</view>
<view class="checkOrder" catchtap="jump" data-item="{{i.goodsOrderCode}}">查看订单></view>
</view>
</block>
<block wx:if="{{haveCouponsList[index].length > 4}}">
<view class="flex checkList" wx:if="{{!item.checkCoupon}}" catchtap="state" data-key="{{index}}">
<view class="check">查看剩余所有券</view>
<glsx-image webp class="state" src="mine/coupon/down.png" />
</view>
<view class="flex checkList" wx:else catchtap="state" data-key="{{index}}">
<view class="check">收起</view>
<glsx-image webp class="state" src="mine/coupon/up.png" />
</view>
</block>
</block>
<block wx:else>
<view class="online_conpon_ctnr" wx:for="{{item.userCouponList}}" wx:for-item="i" wx:key="id">
<view class="online_conpon">
<view class="price_wrap">
<view>
<text class="num">{{i.denomination || 0}}</text>
<text class="unit">元</text>
</view>
<view class="tip">无门槛</view>
</view>
<view class="info_wrap">
<view class="name">{{i.brandName ? i.brandName + '·' : ''}}{{i.appearance == 2 ? i.goodsName + i.rechargeDenomination : i.goodsName}}</view>
<view class="date" wx:if="{{i.discountType == 8}}">数量:{{i.amount}}</view>
<view class="date">有效期{{i.effectiveDays || 0}}天</view>
<view class="use_btn">去使用</view>
</view>
</view>
</view>
</block>
</view>
</scroll-view>
</view>
<view wx:else class="no_data">
<glsx-image webp class="nodata_bg" src="coupons/no_card_bg.png" />
<view class="nodata_text">暂无优惠券</view>
</view>
</block>
<!-- 定向礼包弹框 -->
<view wx:if="{{showGiftsModal}}" class="gifts_modal flex_ccc">
<view class="gifts_wrap flex_ccc">
<view wx:if="{{giftsList.length>2}}" class="gifts_wrapper flex_ccc">
<image webp mode="widthFix" class="gifts_modal_bg" src="{{imgBaseURL}}gifts_list_bg.png" />
<view class="gifts_content_wrap">
<view wx:for="{{giftsList}}" class="gifts_item_wrap">
<image webp mode="widthFix" class="gifts_item_bg" src="{{imgBaseURL}}gifts_coupons_bg.png" />
<view class="gifts_po_wrap">
<view class="left_widget">
<view class="coup_title">{{item.couponName}}</view>
<view wx:if="{{item.effectiveType==3}}" class="coup_tip">无限期</view>
<view wx:if="{{item.effectiveType==2}}" class="coup_tip">有效期:{{item.receiveStartTime}}-{{item.receiveEndTime}}</view>
<view wx:if="{{item.effectiveType==1}}" class="coup_tip">有效至{{item.receiveEndTime}}</view>
</view>
<view class="right_widget">
<image webp mode="widthFix" bind:tap="toUseGifts" data-item="{{item}}" class="gifts_to_use_bg" src="{{imgBaseURL}}gifts_touse.png" />
</view>
</view>
</view>
<view style="height:88rpx"></view>
</view>
<image webp mode="widthFix" class="gifts_modal_bottom_bg" src="{{imgBaseURL}}gifts_fixed_bottom.png" />
</view>
<view wx:if="{{giftsList.length<3}}" class="mini_widget flex_ccc">
<image webp mode="widthFix" class="mini_header_bg" src="{{imgBaseURL}}gifts_header_bg.png" />
<view class="mini_box_wrap" style="height:{{giftsList.length==2?408:298}}rpx">
<image webp class="mini_box_bg" style="height:{{giftsList.length==2?450:340}}rpx" src="{{imgBaseURL}}gifts_box_bg.png" />
<view style="height:50rpx"></view>
<view wx:for="{{giftsList}}" class="gifts_item_wrap">
<image webp mode="widthFix" class="gifts_item_bg" src="{{imgBaseURL}}gifts_coupons_bg.png" />
<view class="gifts_po_wrap">
<view class="left_widget">
<view class="coup_title">{{item.couponName}}</view>
<view wx:if="{{item.effectiveType==3}}" class="coup_tip">无限期</view>
<view wx:if="{{item.effectiveType==2}}" class="coup_tip">有效期:{{item.receiveStartTime}}-{{item.receiveEndTime}}</view>
<view wx:if="{{item.effectiveType==1}}" class="coup_tip">有效至{{item.receiveEndTime}}</view>
</view>
<view class="right_widget">
<image webp mode="widthFix" bind:tap="toUseGifts" data-item="{{item}}" class="gifts_to_use_bg" src="{{imgBaseURL}}gifts_touse.png" />
</view>
</view>
</view>
</view>
</view>
<image webp mode="widthFix" bind:tap="clickClose" class="gifts_modal_btn" src="{{imgBaseURL}}gifts_comfirm_btn.png" />
</view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
// packageMine/pages/order/afterSaleDetail/afterSaleDetail.js
Page({
/**
* 页面的初始数据
*/
data: {
refundStatus: {
1: '待处理',
2: '待发货',
3: '待确认收到退货',
4: '退款中',
5: '已退款',
6: '退款失败',
7: '审核不通过'
},
// 退款状态1:待处理,2待发货,3待确认收到退货,4:退款中,5:已退款,6:退款失败,7:审核不通过
afterSaleObj: [
{
title: '售后类型',
key: 'refundType',
enum: {
1: '我要退款退货',
2: '我要退款(无需退货)'
}
},
{
title: '售后商品',
isArray: true,
key: 'goodsNames'
},
{
title: '申请金额',
key: 'refundPrice'
},
{
title: '申请时间',
key: 'time'
},
{
title: '申请描述',
key: 'remark'
},
{
title: '订单编号',
key: 'orderCode'
}
]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.p.router.getData(orderCode => {
this.getOrderRefundDetail(orderCode)
})
},
getOrderRefundDetail(orderCode) {
wx.p.wxApi.showLoading('加载中...')
wx.p.api.shopmallApi.getOrderRefundDetail(orderCode).then(data => {
wx.hideLoading()
console.log(data)
if (data.refundStatus == 2 && data.refundType == 1) {
wx.p.router.redirectTo('/packageMine/pages/order/afterSale_step_three/afterSale_step_three', data)
return
}
data.time = new Date(data.createdDate).format('yyyy-MM-dd hh:mm:ss')
this.setData({
orderInfo: data
})
})
},
confirm() {
let { orderInfo } = this.data
console.log(orderInfo)
wx.p.router.go('/packageMine/pages/order/afterSale_step_two/afterSale_step_two', orderInfo)
},
previewImage(e) {
let params = e.currentTarget.dataset
wx.p.wxApi.previewImage(params)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {}
})
{
"navigationBarTitleText": "售后详情"
}
\ No newline at end of file \ No newline at end of file
.layout {
padding: 32rpx;
}
.status-box {
text-align: center;
}
.status-box .icon {
margin: 80rpx auto 84rpx;
width: 140rpx;
height: 140rpx;
}
.status-box .title {
font-size: 40rpx;
font-weight: 500;
}
.status-box .tips {
margin: 20rpx 0 59rpx;
color: #656566;
}
.box {
border-radius: 8rpx;
background-color: #fff;
}
.text-box {
padding: 32rpx 24rpx;
border-bottom: 2rpx solid #EFF0F2;
}
.text-box .item{
margin-bottom: 12rpx;
display: flex;
align-items: flex-start;
}
.text-box .item .label{
width: 140rpx;
}
.text-box .item .value{
color: #656566;
width: calc(100% - 150rpx);
}
.photo-box {
padding: 40rpx 0 28rpx 20rpx;
display: flex;
flex-wrap: wrap;
}
.photo-box .item {
width: 200rpx;
height: 200rpx;
background: #D8D8D8;
margin: 0 20rpx 20rpx 0;
}
\ No newline at end of file \ No newline at end of file
<block wx:if="{{orderInfo}}">
<view class="layout isFullSucreen">
<view class="status-box">
<!-- 退款状态1:待处理,2待发货,3待确认收到退货,4:退款中,5:已退款,6:退款失败,7:审核不通过 -->
<view class="icon">
<block wx:if="{{orderInfo.refundStatus == 5}}">
<glsx-image webp src="mine/order/success.png"></glsx-image>
</block>
<block wx:elif="{{orderInfo.refundStatus <5}}">
<glsx-image webp src="mine/order/wait.png"></glsx-image>
</block>
<block wx:else>
<glsx-image webp src="mine/order/error.png"></glsx-image>
</block>
</view>
<view class="title">{{refundStatus[orderInfo.refundStatus]}}</view>
<view class="tips">
<block wx:if="{{orderInfo.refundStatus == 5}}">
钱款将原路退回至您的账户
</block>
<block wx:elif="{{orderInfo.refundStatus > 5 }}">退款不成功,您可以再次提交退款申请重试</block>
<block wx:else>等待平台处理</block>
</view>
</view>
<view class="box">
<view class="text-box">
<block wx:for="{{afterSaleObj}}" wx:key="index">
<view class="item">
<view class="label">{{item.title}}:</view>
<view class="value">
<block wx:if="{{item.enum}}">
{{item.enum[orderInfo[item.key]]}}
</block>
<block wx:elif="{{item.isArray}}">
<block wx:for="{{orderInfo[item.key]}}" wx:key="index" wx:for-item="i">
<text>{{i}};</text>
</block>
</block>
<block wx:else>
{{orderInfo[item.key] || ''}}
</block>
</view>
</view>
</block>
<block wx:if="{{orderInfo.deliveryCompany}}">
<view class="item">
<view class="label">快递公司:</view>
<view class="value">{{orderInfo.deliveryCompany}}</view>
</view>
<view class="item">
<view class="label">快递单号:</view>
<view class="value">{{orderInfo.deliveryNumber}}</view>
</view>
</block>
</view>
<block wx:if="{{orderInfo.imgUrls && orderInfo.imgUrls.length}}">
<view class="photo-box">
<block wx:for="{{orderInfo.imgUrls}}" wx:key="index">
<view class="item" bindtap="previewImage" data-current="{{item}}" data-urls="{{orderInfo.imgUrls}}">
<image webp src="{{item}}"></image>
</view>
</block>
</view>
</block>
</view>
<block wx:if="{{orderInfo.refundStatus >5}}">
<view class="default-btn" bindtap="confirm">重新提交</view>
</block>
</view>
</block>
\ No newline at end of file \ No newline at end of file
import { afterSaleMixin } from '~/mixins/index'
Page({
behaviors: [afterSaleMixin],
/**
* 页面的初始数据
*/
data: {
afterSaleList: [
{
active: true,
value: 2
},
{
value: 1
}
]
},
choose(e) {
let { index } = e.currentTarget.dataset
let { afterSaleList } = this.data
afterSaleList.map(i => (i.active = false))
afterSaleList[index].active = true
this.setData({
afterSaleList
})
},
click() {
let {
orderObj,
data: { afterSaleList }
} = this
orderObj.refundType = 2
afterSaleList.map(e => {
if (e.active) orderObj.refundType = e.value
})
wx.p.router.go('/packageMine/pages/order/afterSale_step_two/afterSale_step_two', orderObj)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.orderObj = options
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {}
})
{
"navigationBarTitleText": "申请售后"
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/order/afterSale_step_one/afterSale_step_one.wxss *//* packageMine/pages/order/afterSale_step_one/afterSale_step_one.wxss */
.layout {
padding: 24rpx var(--margin);
}
.title {
font-size: 32rpx;
font-weight: 500;
margin-bottom: 40rpx;
}
.item {
border: 4rpx solid transparent;
height: 152rpx;
position: relative;
background-color: #fff;
font-size: 40rpx;
margin-bottom: var(--margin);
border-radius: 8rpx;
overflow: hidden;
}
.item.active{
border-color: var(--btnColor);
}
.default-btn{
margin: 220rpx auto 0;
}
.active .icon{
position: absolute;
top: 0;
right: 0;
width: 64rpx;
height: 64rpx;
}
\ No newline at end of file \ No newline at end of file
<view class="layout">
<view class="title">请选择售后类型</view>
<view class="box">
<block wx:for="{{afterSaleList}}" wx:key="index">
<view class="item text-center {{item.active?'active':''}}" bindtap="choose" data-index="{{index}}">
{{afterType[item.value]}}
<view class="icon">
<image webp src="{{IMGURL}}mine/active.png?v={{img_version}}"></image>
</view>
</view>
</block>
</view>
</view>
<view class="default-btn" bindtap="click">确定</view>
\ No newline at end of file \ No newline at end of file
// packageMine/pages/order/afterSale_step_three/afterSale_step_three.js
Page({
/**
* 页面的初始数据
*/
data: {},
onLoad(options) {
this.setData({
orderInfo: options
})
},
input(e) {
let { value } = e.detail
let { key } = e.currentTarget.dataset
this.setData({
[`params.${key}`]: value
})
},
confirm() {
let { orderInfo, params } = this.data
if (!params.deliveryCompany && !params.deliveryNumber) {
wx.p.wxApi.showToast('请填写快递公司、单号')
return
}
params.id = orderInfo.id
wx.p.wxApi.showLoading('提交申请中...')
wx.p.api.shopmallApi.addDelivery(params).then(data => {
console.log(data)
wx.p.wxApi.showToast('申请成功!')
setTimeout(() => {
wx.p.router.back(prevPage => {
prevPage.clearData()
})
}, 1.5 * 1000)
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {}
})
{
"navigationBarTitleText": "申请售后"
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/order/afterSale_step_three/afterSale_step_three.wxss */
.layout {
padding: 0 32rpx;
}
.title {
padding: 32rpx 0 24rpx;
}
.address {
background: #EFF0F2;
border-radius: 8rpx;
overflow-y: scroll;
box-sizing: border-box;
padding: 28rpx 32rpx;
line-height: 40rpx;
}
.box {
height: 216rpx;
background-color: #fff;
border-radius: 8rpx;
position: relative;
}
.box::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 654rpx;
height: 2rpx;
background: #EFF0F2;
transform: translate(-50%,-50%);
}
.item {
height: 108rpx;
display: flex;
align-items: center;
box-sizing: border-box;
}
.item .label{
width: 224rpx;
text-indent: 32rpx;
}
.item .input{
width: calc(100% - 256rpx);
}
.btn {
margin: 48rpx auto 20rpx;
width: 332rpx;
height: 80rpx;
background: var(--btnColor);
border-radius: 8rpx;
color: #fff;
}
.disabled{
background-color: #999;
}
\ No newline at end of file \ No newline at end of file
<view class="layout">
<view class="title">请将收到的货物发回以下地址</view>
<view class="address">
<view>地址:{{orderInfo.contactAddress}}</view>
<view>收货人:{{orderInfo.contactName}}</view>
<view>联系电话:{{orderInfo.contactPhone}}</view>
</view>
<view class="title">请输入您的快递信息</view>
<view class="box">
<view class="item">
<view class="label">快递公司</view>
<input class="input" type="text" placeholder="请输入" bindinput="input" data-key="deliveryCompany" />
</view>
<view class="item">
<view class="label">快递单号</view>
<input class="input" type="text" placeholder="请输入" bindinput="input" data-key="deliveryNumber" />
</view>
</view>
<view class="btn text-center {{params.deliveryCompany && params.deliveryNumber?'':'disabled'}}" bindtap="confirm">提交申请
</view>
</view>
\ No newline at end of file \ No newline at end of file
import {
afterSaleMixin
} from '~/mixins/index'
Page({
behaviors: [afterSaleMixin],
/**
* 页面的初始数据
*/
data: {
imgUrls: []
},
previewImage(e) {
let params = e.currentTarget.dataset
wx.p.wxApi.previewImage(params)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let imgUrls = []
if (options.imgUrls) imgUrls = options.imgUrls
this.setData({
orderObj: options,
imgUrls,
maxPrice: options.refundPrice
})
},
input(e) {
this.setData({
'orderObj.remark': e.detail.value
})
},
noScroll() {},
changePrice() {
this.setData({
showPriceInput: true
})
},
blur(e) {
const rex = /^(([1-9]{1}\d*)|(0{1}))(\.\d{2})$/
console.log(e)
let {
value
} = e.detail
let {
maxPrice
} = this.data
if (value > maxPrice) value = maxPrice
if (value < 0) value = 0
if (!rex.test(value)) value = maxPrice
this.setData({
'orderObj.refundPrice': Number(value).toFixed(2),
showPriceInput: false
})
},
del(e) {
let {
index
} = e.currentTarget.dataset
let {
imgUrls
} = this.data
imgUrls.splice(index, 1)
this.setData({
imgUrls
})
},
upLoad() {
let _this = this
let {
imgUrls
} = this.data
wx.chooseImage({
count: 1
}).then(res => {
let [tempFiles] = res.tempFilePaths
let imgType = tempFiles.split('.')[1]
let type = imgType == 'unknown' ? 'jpg' : imgType
wx.getFileSystemManager().readFile({
filePath: tempFiles, //选择图片返回的相对路径
encoding: 'base64', //编码格式
success(_res) {
wx.p.wxApi.showLoading('上传中...')
commonApi
.uploadImg({
file: `${type}@${_res.data}`
})
.then(img => {
wx.p.wxApi.hideLoading()
console.log(img)
imgUrls.push(img)
_this.setData({
imgUrls
})
})
}
})
})
},
confirm() {
let {
orderObj,
imgUrls
} = this.data
orderObj.imgUrls = imgUrls
console.log(orderObj)
wx.p.api.shopmallApi.afterSale(orderObj).then(({
code,
data,
message
}) => {
if (code == '0') {
wx.p.wxApi.showToast('申请成功!')
setTimeout(() => {
wx.p.router.back(prevPage => {
prevPage.clearData()
}, 2)
}, 1.5 * 1000)
} else {
wx.p.wxApi.showToast(message)
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {}
})
\ No newline at end of file \ No newline at end of file
{
"navigationBarTitleText": "申请售后"
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/order/afterSale_step_two/afterSale_step_two.wxss */
.layout {
padding: 0 var(--margin) 24rpx;
}
.title {
font-weight: 500;
font-size: 32rpx;
padding: 24rpx 0;
}
.box {
background: #FFFFFF;
border-radius: 8rpx;
}
.type {
height: 104rpx;
background: #EFF0F2;
border-radius: 8rpx;
font-size: 40rpx;
}
.description {
height: 460rpx;
box-sizing: border-box;
padding: 28rpx 32rpx;
}
.price-box {
height: 100rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin: 24rpx 0 8rpx;
box-sizing: border-box;
padding: 0 32rpx;
}
.price-box .value {
font-size: 24rpx;
color: var(--btnColor);
display: flex;
align-items: center;
}
.price-box .value .price {
margin-right: 28rpx;
font-size: 36rpx;
}
.upload-box {
min-height: 260rpx;
box-sizing: border-box;
padding: 30rpx 0 0 22rpx;
}
.upload-box .one {
width: 100%;
height: 260rpx;
}
.upload-box.flex {
display: flex;
flex-wrap: wrap;
}
.upload-box .icon {
width: 84rpx;
height: 64rpx;
}
.upload-box .item {
width: 200rpx;
height: 200rpx;
background: #D8D8D8;
margin-bottom: 30rpx;
margin-right: 20rpx;
position: relative;
}
.item .del {
position: absolute;
width: 72rpx;
height: 72rpx;
right: -32rpx;
top: -32rpx;
}
.upload-box .item .del .icon {
width: 36rpx;
height: 36rpx;
}
.upload-box .upload-item {
background-color: #fff;
border: 2rpx solid #D8D8D8;
box-sizing: border-box;
}
.btn {
margin: 48rpx auto 20rpx;
width: 332rpx;
height: 80rpx;
background: var(--btnColor);
border-radius: 8rpx;
color: #fff;
}
.price-input-box {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 2;
background-color: rgba(0, 0, 0, .7);
}
.price-input {
width: 100%;
height: 72rpx;
background-color: #fff;
box-sizing: border-box;
padding: 0 40rpx;
display: flex;
align-items: center;
}
\ No newline at end of file \ No newline at end of file
<view class="layout isFullSucreen">
<view class="title">售后类型</view>
<view class="type text-center">
{{afterType[orderObj.refundType]}}
</view>
<view class="title">申请描述</view>
<view class="description box">
<gl-textarea maxlength="230" value="{{orderObj.remark}}" bindinput="input" showWordLimit customMaxLength></gl-textarea>
</view>
<view class="price-box box">
申请金额
<view class="value" bindtap="changePrice">
<view class="price">¥{{orderObj.refundPrice}}</view>
修改金额
</view>
</view>
<view class="title">上传图片</view>
<view class="upload-box box flex">
<block wx:if="{{imgUrls.length < 1}}">
<view class="one text-center" bindtap="upLoad">
<view class="icon">
<image webp src="{{IMGURL}}mine/camera.png?v={{img_version}}"></image>
</view>
</view>
</block>
<block wx:else>
<block wx:for="{{imgUrls}}" wx:key="index">
<view class="item" catchtap="previewImage" data-current="{{item}}" data-urls="{{imgUrls}}">
<image webp src="{{item}}"></image>
<view class="del text-center" catchtap="del" data-index="{{index}}">
<view class="icon">
<image webp src="{{IMGURL}}mine/del.png?v={{img_version}}"></image>
</view>
</view>
</view>
</block>
<block wx:if="{{imgUrls.length < 5}}">
<view class="upload-item item text-center" bindtap="upLoad">
<view class="icon">
<image webp src="{{IMGURL}}mine/camera.png?v={{img_version}}"></image>
</view>
</view>
</block>
</block>
</view>
<view class="btn text-center" bindtap="confirm">提交申请</view>
</view>
<block wx:if="{{showPriceInput}}">
<view class="price-input-box" catchtouchmove="noScroll">
<view class="price-input">
<input type="digit" bindblur="blur" value="{{orderObj.refundPrice}}" focus="{{showPriceInput}}" class="input"
adjust-position="{{false}}" />
</view>
</view>
</block>
\ No newline at end of file \ No newline at end of file
// packageMine/pages/order/complete/complete.js
Page({
/**
* 页面的初始数据
*/
data: {
success: false,
count: 5
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options.success) {
this.setData(options)
this.countdown()
} else {
this.setData({
params: options.params
})
}
},
countdown() {
this.timer = setInterval(() => {
let { count } = this.data
if (count == 0) {
clearInterval(this.timer)
wx.p.router.reLaunch('/packageMine/pages/order/index/index')
return
}
this.setData({
count: --count
})
}, 1 * 1000)
},
pay() {
let { params } = this.data
let _this = this
wx.requestPayment({
...params,
success(res) {
_this.setData({
success: true
})
_this.countdown()
},
fail(res) {
if (res.errMsg == 'requestPayment:fail cancel') {
wx.$api.showToast('取消支付')
}
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
if (this.timer) clearInterval(this.timer)
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
if (this.timer) clearInterval(this.timer)
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {}
})
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/order/complete/complete.wxss */
page {
background-color: #fff;
}
.layout {
display: flex;
align-items: center;
flex-direction: column;
}
.icon {
width: 140rpx;
height: 140rpx;
margin: 112rpx 0 84rpx;
}
.title {
font-size: 40rpx;
font-weight: 500;
margin-bottom: 64rpx;
}
.text {
color: #656566;
font-size: 32rpx;
}
.tips {
color: #B9BABB;
margin-top: 20rpx;
}
.pay {
width: 332rpx;
height: 80rpx;
background: var(--btnColor);
border-radius: 8rpx;
color: #fff;
margin-top: 112rpx;
}
\ No newline at end of file \ No newline at end of file
<view class="layout">
<view class="icon">
<glsx-image webp src="mine/order/{{success?'success':'error'}}.png"></glsx-image>
</view>
<view class="title">{{success?'支付成功':'支付失败'}}</view>
<block wx:if="{{success}}">
<view class="text">您的订单已支付成功,请耐心等待商品发货!</view>
<view class="tips">{{count}}秒后自动跳转到商城订单</view>
</block>
<block wx:else>
<view class="pay text-center" bindtap="pay">重新支付</view>
</block>
</view>
\ No newline at end of file \ No newline at end of file
import QR from '~/utils/lib/wxqrcode'
import {
orderMixin
} from '~/mixins/index'
import {
iosTimeFormat,
} from '~/utils/format'
Page({
behaviors: [orderMixin],
/**
* 页面的初始数据
*/
data: {
couponsList: [],
orderObj: [{
label: '下单日期',
key: 'time'
},
{
label: '订单编号',
key: 'orderCode'
},
{
label: '收货地址',
key: 'shipAddress',
alignItems: 'flex-start'
},
{
label: '订单状态',
key: 'orderStatus',
enum: true
}
],
deliveryStatus: {
1: '待发货',
2: '已发货',
3: '已收货'
}
},
onRoute(orderCode) {
if (Object.keys(orderCode).length !== 0) {
console.log(orderCode)
this.getOrderDetail(orderCode)
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options && options.orderCode) {
let orderCode = options.orderCode
this.getOrderDetail(orderCode)
}
},
getOrderDetail(orderCode) {
let {
orderObj
} = this.data
wx.p.wxApi.showLoading('加载中...')
wx.p.api.shopmallApi.getOrderDetail(orderCode).then(data => {
wx.hideLoading()
console.log(data)
data.time = new Date(iosTimeFormat(data.createdDate)).format('yyyy.MM.dd hh:mm:ss')
data.orderGoods.map(e => {
e.retailPrice = Number(e.retailPrice).toFixed(2)
if (e.activityPrice) e.activityPrice = Number(e.activityPrice).toFixed(2)
})
data.orderPrice = Number(data.orderPrice).toFixed(2)
data.expressFee = Number(data.expressFee).toFixed(2)
data.payPrice = Number(data.payPrice).toFixed(2)
if (data.orderSource == 4) {
orderObj[2] = {
label: '商户订单号',
key: 'outTradeNo',
}
}
this.setData({
orderInfo: data,
orderObj
})
if (data.deliveryType == 1 && data.orderVerification) this.setQr(data.orderVerification.verificationCode)
if (data.relatedUserCoupon) {
let list = data.relatedUserCoupon.map(item => {
item.receiveStartTime = new Date(iosTimeFormat(item.receiveStartTime)).format('yyyy.MM.dd')
if (item.effectiveType == 1) {
item.receiveEndTime = new Date(iosTimeFormat(item.receiveEndTime)).format('yyyy.MM.dd hh:mm:ss')
} else {
item.receiveEndTime = new Date(iosTimeFormat(item.receiveEndTime)).format('yyyy.MM.dd')
}
return item
})
this.setData({
couponsList: list
})
}
})
},
toDetail() {
let [temp] = this.data.orderInfo.relatedUserCoupon, {
discountType,
useChannel,
id
} = temp, detailInfo = {
xx: 'xx'
}
if (discountType == 2 || discountType == 4) {
wx.p.router.go('/packageMall/pages/coupon/coupon', {
userCouponId: id,
useMemberType: this.data.useMemberType,
detailInfo
})
return
}
/**线上商品代金券 */
if (discountType == 3 && useChannel == 1) {
if (this.data.useMemberType == 1) {
wx.p.wxApi.showToast('代金券已使用')
return
}
wx.p.router.go('/packageMine/pages/coupon/recommend/recommend', {
couponInfo: temp
})
return
}
wx.p.router.go('/packageMine/pages/coupon/detail/detail', {
item: temp
})
},
setQr(data) {
this.setData({
qr: QR.createQrCodeImg(`t=1&c=${data}`)
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {}
})
\ No newline at end of file \ No newline at end of file
{
"navigationBarTitleText": "订单详情"
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/order/detail/detail.wxss */
.layout {
padding: 24rpx 32rpx 68rpx;
}
.status-box {
height: 98rpx;
font-size: 36rpx;
color: #2C2C2C;
margin-bottom: 6rpx;
}
.status-box .icon{
width: 50rpx;
height: 52rpx;
margin-right: 12rpx;
}
.box {
background-color: #fff;
border-radius: var(--borderRadius);
margin-top: 20rpx;
padding: 24rpx 24rpx 40rpx;
}
.box:first-of-type{
margin-top: 0;
}
.box .title {
font-size: 32rpx;
padding-bottom: 24rpx;
font-weight: 500;
}
.box .item {
display: flex;
align-items: center;
font-size: 24rpx;
min-height: 48rpx;
line-height: 48rpx;
}
.box .item.flex-start {
align-items: flex-start;
}
.box .item .label {
width: 150rpx;
}
.box .item .value {
width: calc(100% - 150rpx);
color: #656566;
}
.box .goods {
margin-top: 40rpx;
display: flex;
align-items: center;
height: 160rpx;
}
.box .goods .icon {
width: 160rpx;
height: 100%;
overflow: hidden;
border-radius: var(--borderRadius);
margin-right: 20rpx;
}
.box .goods .info {
width: calc(100% - 180rpx);
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.box .goods .info .name {
font-size: 30rpx;
color: #333;
}
.box .goods .info .specification{
font-size: 24rpx;
color: #B1B1B3;
}
.box .goods .info .price {
display: flex;
justify-content: space-between;
color: var(--btnColor);
font-weight: 500;
font-weight: 500;
}
.box .goods .info .price .count {
color: #656566;
font-weight: normal;
}
.price-item {
height: 60rpx;
display: flex;
justify-content: space-between;
align-items: center;
color: #656566;
font-size: 24rpx;
}
.price-item.line {
border-bottom: 2rpx solid #E3E3E6;
margin-bottom: 12rpx;
}
.price-item .price {
font-size: 28rpx;
color: var(--btnColor);
font-weight: 500;
}
.price-item .sum{
font-size: 34rpx;
font-weight: 500;
}
.price-item .unit{
font-size: 28rpx;
}
.discounts {
position: relative;
}
.discounts .selected {
height: 40rpx;
background: rgba(252, 91, 50, 0.12);
border-radius: 4rpx;
font-size: 24rpx;
font-weight: 500;
color: var(--btnColor);
line-height: 40rpx;
padding: 0 20rpx;
position: absolute;
left: 104rpx;
top: 50%;
transform: translate(0, -50%);
}
.qr-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.qr-box .qr {
width: 250rpx;
height: 250rpx;
background: #FFF;
border: 2rpx solid #979797;
box-sizing: border-box;
padding: 10rpx;
}
.qr-box .code {
font-size: 64rpx;
margin: 20rpx 0;
color: var(--btnColor);
}
.qr-box .tips {
color: #656566;
font-size: 24rpx;
padding-bottom: 28rpx;
}
.box_wrapper {
width: 100%;
height: 150rpx;
margin-top: 19rpx;
display: flex;
align-items: center;
position: relative;
box-sizing: border-box;
background-size: cover;
}
.box_wrapper .bg{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.box_wrapper .info{
position: relative;
z-index: 2;
width: 100%;
height: 100%;
}
.left_icon_box {
width: 156rpx;
height: 156rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.left_bg {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 156rpx;
height: 156rpx;
z-index: 1;
}
.left_text_one {
font-size: 36rpx;
font-weight: 600;
color: #FFFFFF;
z-index: 2;
}
.left_text_two {
display: flex;
align-items: flex-end;
}
.left_text_four {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.left_text_three {
font-size: 20rpx;
margin-top: 6rpx;
}
.anText {
font-size: 70rpx;
/* color: rgba(white, white, white, 0.45); */
font-weight: 600;
color: var(--btnColor);
/* opacity: 0.45; */
}
.price_icon {
font-size: 24rpx;
margin-bottom: 7rpx;
font-weight: 500;
}
.main_box {
height: 156rpx;
box-sizing: border-box;
padding: 24rpx 24rpx 24rpx 0rpx;
justify-content: space-evenly;
display: flex;
flex-direction: column;
z-index: 1;
}
.box_btn {
position: absolute;
right: 47rpx;
top: 50%;
transform: translate(0, -50%);
width: 120rpx;
height: 44rpx;
text-align: center;
line-height: 44rpx;
font-size: 28rpx;
font-weight: 600;
z-index: 2;
}
.box_btn_color {
color: var(--btnColor);
}
.box_btn_color_grey {
color: #6D6D6D;
}
.title_text {
color: #282829;
font-weight: 600;
color: #282829;
font-size: 28rpx;
width: 420rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.h4_text {
font-weight: 400;
color: #B1B1B3;
font-size: 24rpx;
}
.brightColor {
color: var(--btnColor);
}
.darkColor {
color: #6D6D6D;
}
.describeColor {
color: #D83C14;
}
.discount {
font-size: 20rpx;
font-weight: 500;
margin-bottom: 10rpx;
}
.leftMargin {
padding-left: 32rpx;
}
\ No newline at end of file \ No newline at end of file
<block wx:if="{{orderInfo}}">
<view class="layout">
<view class="box">
<view class="status-box text-center">
<view class="icon">
<!-- // 订单状态(1:待付款;2:已支付;3:已关闭;4:已发货;5:已收货;6:待审核;7:审核通过;8:审核不通过;9:待确认收到退货;10:退款中;11:已退款;12:退款失败) -->
<block wx:if="{{orderInfo.orderStatus == 1||orderInfo.orderStatus == 13||orderInfo.orderStatus==14}}">
<glsx-image webp src="mine/order-wait.png"></glsx-image>
</block>
<block wx:elif="{{orderInfo.orderStatus == 2||orderInfo.orderStatus == 4 }}">
<glsx-image webp src="mine/order-receiving.png"></glsx-image>
</block>
<block wx:elif="{{orderInfo.orderStatus == 5||orderInfo.orderStatus == 15}}">
<glsx-image webp src="mine/order-success.png"></glsx-image>
</block>
<block wx:else>
<glsx-image webp src="mine/order-lose.png"></glsx-image>
</block>
</view>
{{statusEnum[orderInfo.orderStatus]}}
</view>
<block wx:if="{{orderInfo.deliveryCompany}}">
<view class="title">发货信息</view>
<view class="item">
<view class="label">物流信息:</view>
<view class="value">{{orderInfo.deliveryCompany || ''}}{{orderInfo.deliveryNumber || ''}}</view>
</view>
<view class="item">
<view class="label">物流进度:</view>
<view class="value">
{{deliveryStatus[orderInfo.deliveryStatus]}}
</view>
</view>
</block>
</view>
<view class="box">
<view class="title">订单信息</view>
<block wx:for="{{orderObj}}" wx:key="index">
<view class="item {{item.alignItems}}">
<view class="label">{{item.label}}:</view>
<view class="value">
<block wx:if="{{item.enum}}">
{{statusEnum[orderInfo[item.key]]|| ''}}
</block>
<block wx:else>{{orderInfo[item.key] || ''}}</block>
</view>
</view>
</block>
</view>
<view class=" box">
<view class="title">订单商品</view>
<view class="merchantName text-hide">
{{orderInfo.merchantName}}
</view>
<block wx:key="index" wx:for="{{orderInfo.orderGoods}}">
<view class="goods">
<view class="icon">
<image webp src="{{orderInfo.orderSource == 5?orderInfo.activityBigImg:item.goodsImage}}"></image>
</view>
<view class="info">
<view>
<view class="name text-hide">{{orderInfo.orderSource == 5?orderInfo.activityName:item.goodsName}}</view>
<view class="specification">{{item.specificationData || ''}}</view>
</view>
<view class="price">
¥{{orderInfo.orderSource == 5?orderInfo.payPrice:(item.activityPrice || item.retailPrice)}}
<view class="count">x{{orderInfo.orderSource == 5? 1: item.goodsNumber}}</view>
</view>
</view>
</view>
</block>
</view>
<view class="box" wx:if="{{orderInfo.orderSource!=5}}">
<view class="title">订单金额</view>
<view class="price-item">
商品总价:
<view class="price"><text class="unit">¥</text>{{orderInfo.orderPrice}}</view>
</view>
<view class="price-item line">
运费:
<view class="price"><text class="unit">¥</text>{{orderInfo.expressFee}}</view>
</view>
<view class="price-item line discounts" wx:if="{{orderInfo.subOrderCoupon.denomination}}">
优惠:
<view class="selected">已选一张</view>
<view class="price"><text class="unit">¥</text>{{(orderInfo.subOrderCoupon.discountAmount)/100}}</view>
</view>
<view class="price-item">
订单金额:
<view class="price sum"><text class="unit">¥</text>{{orderInfo.payPrice}}</view>
</view>
</view>
<!-- deliveryType 结算方式(1:到店核销,2:快递发货) -->
<block wx:if="{{orderInfo.deliveryType == 1 && qr && !orderInfo.relatedUserCoupon}}">
<view class="box">
<view class="title">核销码</view>
<view class="qr-box">
<view class="qr">
<image webp src="{{qr}}"></image>
</view>
<view class="code">{{orderInfo.orderVerification.verificationCode}}</view>
<view class="tips">请将核销码拿给店员,避免泄露给他人</view>
</view>
</view>
</block>
<view class="box" wx:if="{{orderInfo.relatedUserCoupon}}">
<view class="title">关联优惠券</view>
<block wx:for="{{couponsList}}" wx:key="index">
<view class="box_wrapper">
<glsx-image webp src="mine/coupon/{{item.usedAmount == 0?'':'un-'}}coupon-{{item.discountType}}.png" class="bg"></glsx-image>
<view class="info flex">
<view class="{{item.discountType==4 || item.discountType==7 ? '':'left_icon_box'}}">
<view wx:if="{{item.discountType==3}}" class="left_text_one left_text_two {{item.usedAmount == 0 ? 'brightColor':'darkColor'}}">
<text class="price_icon">¥</text>
<text>{{item.denomination}}</text>
</view>
<view wx:if="{{item.discountType==2}}" class="left_text_one left_text_two {{item.usedAmount == 0 ? 'brightColor':'darkColor'}}">
<text class="anText">{{item.discountIntensity / 100}}</text>
<text class="discount">折</text>
</view>
</view>
<view class="main_box {{item.discountType==4 || item.discountType==7 ? 'leftMargin':''}}">
<view class="title_text {{item.usedAmount == 0 ? 'brightColor':'darkColor'}}">{{item.couponName}}</view>
<view wx:if="{{item.useType==0 && coupons.discountType==7}}" class="h4_text {{item.usedAmount == 0 ? 'describeColor':'darkColor'}}">不限次数</view>
<view wx:if="{{item.useType==1 && coupons.discountType==7}}" class="h4_text {{item.usedAmount == 0 ? 'describeColor':'darkColor'}}">可用{{item.useAmount}}次</view>
<view wx:if="{{item.useType==2 && coupons.discountType==7}}" class="h4_text {{item.usedAmount == 0 ? 'describeColor':'darkColor'}}">{{item.useLimitDays}}天可用{{item.useAmount}}次</view>
<view wx:if="{{item.useBarriers==1 && item.discountType!=4}}" class="h4_text {{item.usedAmount == 0 ? 'describeColor':'darkColor'}}">无门槛</view>
<view wx:if="{{item.useBarriers==2 && item.discountType!=4}}" class="h4_text {{item.usedAmount == 0 ? 'describeColor':'darkColor'}}">满{{item.full}}元可用</view>
<view wx:if="{{item.effectiveType==3}}" class="h4_text {{item.usedAmount == 0 ? 'describeColor':'darkColor'}}">永久有效</view>
<view wx:if="{{item.effectiveType==2}}" class="h4_text {{item.usedAmount == 0 ? 'describeColor':'darkColor'}}">{{item.receiveStartTime}}-{{item.receiveEndTime}}</view>
<view wx:if="{{item.effectiveType==1}}" class="h4_text {{item.usedAmount == 0 ? 'describeColor':'darkColor'}}">有效至{{item.receiveEndTime}}</view>
</view>
<block wx:if="{{!hideBtn}}">
<view wx:if="{{item.usedAmount==0}}" class="box_btn box_btn_color" bind:tap="toDetail">去使用</view>
<view wx:if="{{item.usedAmount==1}}" class="box_btn box_btn_color box_btn_color_grey" bind:tap="toDetail">去查看</view>
<view wx:if="{{item.usedAmount==2}}" class="box_btn box_btn_color box_btn_color_grey" bind:tap="toDetail">去查看</view>
</block>
</view>
</view>
</block>
</view>
</view>
</block>
\ No newline at end of file \ No newline at end of file
// packageMine/pages/order/index/index.js
import {
orderMixin
} from '~/mixins/index'
import NP from 'number-precision'
/**查询订单
* '全部 ', '待付款 1', '待发货 3', '待收货 2', '评价 4', '退款/售后 5'
*/
const orderStatusPartEnum = {
0: '',
1: 1,
2: 3,
3: 2,
4: 5,
}
Page({
behaviors: [orderMixin],
/**
* 页面的初始数据
*/
data: {
pageNum: 1,
tab: ['全部', '待付款', '待发货', '待收货', '退款/售后'],
list: [],
hasUserInfo: false,
},
navbarReady(e) {
wx.p.wxApi.getViewInfo('.tab', (res) => {
this.setData({
padding_bottom: e.detail.height,
margin_top: e.detail.height + res.height,
})
})
},
jump(e) {
let {
item: {
orderStatus,
orderCode,
orderSource
},
} = e.currentTarget.dataset
if (orderSource == 5 && (orderStatus == 2 || orderStatus == 7)) return
console.log(e)
let url = '/packageMine/pages/order/detail/detail'
wx.p.router.go(url, {
orderCode
})
},
afterSaleDetail(e) {
let url = '/packageMine/pages/order/afterSaleDetail/afterSaleDetail'
let {
item: {
orderCode
},
} = e.currentTarget.dataset
wx.p.router.go(url, {
orderCode
})
},
back() {
let {
length
} = getCurrentPages()
if (length == 1) wx.p.router.switchTab('/pages/tab/mine/index')
else wx.p.router.back()
},
changeTab(e) {
console.log('e', e)
this.setData({
tabIndex: e.detail,
orderStatusPart: orderStatusPartEnum[e.detail],
})
this.clearData()
},
//立即评价
evaluate(e) {
let {
item: {
orderCode
},
} = e.currentTarget.dataset
let {
userInfo
} = this.data
console.log(orderCode)
wx.p.router.go('/packageMall/pages/addComment/addComment', {
orderCode,
userInfo,
})
},
//查看详情评价
lookevaluate(e) {
let {
item: {
orderCode
},
} = e.currentTarget.dataset
console.log(orderCode)
wx.p.router.go('/packageMall/pages/commentDetails/commentDetails', orderCode)
},
//取消售后
cancelOrder(e) {
let {
orderCode
} = e.currentTarget.dataset
wx.showModal({
title: '温馨提示',
content: '请问您是否要取消售后',
confirmText: '确认',
cancelText: '取消',
confirmColor: '#F13C3D',
}).then((res) => {
if (res.confirm) {
wx.p.api.shopmallApi.cancelOrder(orderCode).then(({
code,
message
}) => {
if (code == '0') {
wx.p.wxApi.showToast('操作成功')
setTimeout(() => {
this.clearData()
}, 1.5e3)
} else {
wx.p.wxApi.showToast(message)
}
})
}
})
},
//取消付款
cancelPay(e) {
let {
orderCode
} = e.currentTarget.dataset
wx.showModal({
title: '温馨提示',
content: '请问您是否要取消付款',
confirmText: '确认',
cancelText: '取消',
confirmColor: '#F13C3D',
}).then((res) => {
if (res.confirm) {
wx.p.api.shopmallApi.cancelPay(orderCode).then(({
code,
message
}) => {
if (code == '0') {
wx.p.wxApi.showToast('操作成功')
setTimeout(() => {
this.clearData()
}, 1.5e3)
} else {
wx.p.wxApi.showToast(message)
}
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
hasUserInfo: true,
tabIndex: options.tabIndex,
orderStatusPart: orderStatusPartEnum[options.tabIndex],
})
const {
userInfo,
tabIndex
} = this.data
if (userInfo) {
if (tabIndex != options?.tabIndex) delete options.tabIndex
this.setData(options)
this.clearData()
} else this.setData({
showLogin: true,
})
},
clearData() {
this.setData({
listFlag: false,
list: [],
nothing: false,
pageNum: 1,
})
this.getOrderList()
},
search() {
this.clearData()
},
clear() {
this.setData({
keyword: '',
})
},
input(e) {
this.setData({
keyword: e.detail.value,
})
},
blur() {
let {
keyword
} = this.data
this.setData({
keyword,
})
},
getOrderList() {
wx.p.wxApi.showLoading('加载中...')
let {
orderStatusPart,
pageNum,
keyword
} = this.data
let obj = {
orderStatusPart,
currentPage: pageNum,
}
if (keyword) {
keyword = keyword.replace(/\ /g, '')
if (keyword.length) obj.keyword = keyword
}
let list = []
wx.p.api.mineApi.getOrderList(obj).then((data) => {
wx.hideLoading()
console.log('data', data)
data?.list?.map((e) => {
let {
orderGoods,
createdDate,
orderClassify
} = e
let goodsNumber = 0
let expiredTime = 0
orderGoods?.map((i) => {
i.retailPrice = Number(i.retailPrice).toFixed(2)
if (i.activityPrice)
i.activityPrice = Number(i.activityPrice).toFixed(2)
goodsNumber += i.goodsNumber
expiredTime = new Date(i.warrantyDate).format('yyyy-MM-dd hh:mm:ss')
if (orderClassify == 5) {
e.payPrice = NP.times(i.retailPrice, i.goodsNumber)
}
})
list.push({
...e,
goodsNumber,
time: new Date(createdDate).format('yyyy-MM-dd hh:mm:ss'),
expiredTime
})
})
this.setData({
list,
listFlag: true,
})
wx.hideLoading()
})
},
pay(e) {
let _this = this
wx.p.wxApi.showLoading('结算中...')
wx.p.api.shopmallApi
.payOrder(e.currentTarget.dataset)
.then(({
needPay,
payParams
}) => {
wx.hideLoading()
if (needPay) {
let params = {
nonceStr: payParams.nonceStr,
paySign: payParams.paySign,
signType: payParams.signType,
timeStamp: payParams.timeStamp,
package: payParams.packages,
}
wx.requestPayment({
...params,
success(res) {
setTimeout(() => {
_this.clearData()
}, 1.5e3)
_this.requestSubscribeMessage()
},
fail(res) {
if (res.errMsg == 'requestPayment:fail cancel') {
wx.p.wxApi.showToast('取消支付')
} else {
wx.p.router.go('/packageMine/pages/order/complete/complete', {
params
})
}
},
})
} else {
_this.requestSubscribeMessage()
}
})
},
requestSubscribeMessage() {
let systemInfo = wx.p.storage.get('system_info')
if (systemInfo && systemInfo.environment != 'wxwork') {
wx.p.router.go('/packageMine/pages/order/complete/complete', {
success: true,
})
return
}
let tmplIds
wx.p.api.shopmallApi.requestSubscribeMessage().then((res) => {
tmplIds = res.data
wx.requestSubscribeMessage({
tmplIds: tmplIds,
success(res) {
wx.p.router.go('/packageMine/pages/order/complete/complete', {
success: true,
})
},
})
})
},
confirmReceipt(e) {
let {
orderCode
} = e.currentTarget.dataset
wx.showModal({
title: '温馨提示',
content: '是否确认收货',
confirmText: '确认',
cancelText: '取消',
confirmColor: '#F13C3D',
}).then((res) => {
if (res.confirm) {
wx.p.api.shopmallApi.confirmReceipt(orderCode).then((data) => {
wx.p.wxApi.showToast('操作成功')
setTimeout(() => {
this.clearData()
}, 1.5e3)
})
}
})
},
afterSale(e) {
let {
item: {
orderCode,
payPrice
},
} = e.currentTarget.dataset
wx.p.router.go('/packageMine/pages/order/afterSale_step_one/afterSale_step_one', {
orderCode,
refundPrice: payPrice,
})
},
// 卡卷 售后详情
toSaleDetailPage(e) {
const {
item
} = e.currentTarget.dataset
wx.p.router.go('/packageEquity/pages/saleDetail/saleDetail', {
orderCode: item.orderCode
})
},
// 查看卡券
toCheckCard(e) {
const {
item
} = e.currentTarget.dataset
wx.p.router.go('/packageEquity/pages/kaqDetail/kaqDetail', {
orderCode: item.orderCode
})
},
// 查看膨胀金详情
toGoldDetail(e) {
const {
item
} = e.currentTarget.dataset
wx.p.router.go('/packageEquity/pages/kaqDetail/orderDetail', {
orderCode: item.orderCode
})
},
// 卡卷 申请售后
toSaleApplyPage(e) {
let {
item
} = e.currentTarget.dataset
item.pageFrom = 'coupons'
wx.p.router.go('/packageEquity/pages/saleApply/saleApply', item)
},
// 卡卷 确认收货
toComfirmPage(e) {
let {
item
} = e.currentTarget.dataset
let para = {
orderCode: item.orderCode,
}
wx.showModal({
title: '提示',
content: '确认收货',
confirmText: '是',
cancelText: '否',
confirmColor: '#F13C3D',
}).then((res) => {
if (res.confirm) {
equityApi.comfirmRevice(para).then((res) => {
wx.p.wxApi.showToast('确认收货成功')
setTimeout(() => {
this.clearData()
}, 1.5e3)
})
}
})
},
// 套餐申请售后
toSaleApplyPackage(e) {
let {
item
} = e.currentTarget.dataset
item.pageFrom = 'package'
wx.p.router.go('/packageEquity/pages/saleApply/saleApply', item)
},
// 套餐售后详情
toPackageDetail(e) {
const {
item
} = e.currentTarget.dataset
wx.p.router.go('/packageEquity/pages/packageDetail/packageDetail', {
orderCode: item.orderCode
})
},
// 套餐查看卡包
toCheckPackage(e) {
const {
item
} = e.currentTarget.dataset
wx.p.router.go('/packageEquity/pages/packageDetail/packageDetail', {
orderCode: item.orderCode
})
},
// 精品订单跳转页面
boutiqueJump(e) {
let {
orderCode
} = e.currentTarget.dataset
console.log(orderCode)
wx.p.router.go('/packageMine/pages/boutiquePages/boutiqueOrder/boutiqueOrder', {
orderCode,
type: 2,
})
},
/**平台商城跳转 */
async jumpPlatformShop(e) {
let {
item,
url
} = e.currentTarget.dataset
if (item.afterSaleStatus && url == 'afterSaleDetail/index' && item.afterSaleStatus == 8) url = 'applySale/index'
if (url == 'applySale/index') {
const res = await this.getReturnCount(item)
if (!res.applyQty) return wx.p.wxApi.showToast('该商品不支持售后')
item.applyQty = res.applyQty
}
wx.p.router.go(`/packageMall/pages/platformShop/${url}`, item)
},
/**平台商城取消订单*/
cancelPlatformOrder(e) {
wx.showModal({
title: '温馨提示',
content: '请问您是否要取消付款',
confirmText: '确定',
cancelText: '取消',
confirmColor: '#F13C3D',
}).then(async res => {
if (res.confirm) {
wx.p.wxApi.showLoading()
try {
const {
orderCode
} = e.currentTarget.dataset, {
code,
message
} = await wx.p.api.shopmallApi.cancelPlatformOrder({
subOrderCode: orderCode
})
wx.hideLoading()
if (code == 0) {
wx.p.wxApi.showToast('取消成功')
setTimeout(() => {
this.getOrderList()
}, 1.5e3)
} else throw message
} catch (error) {
wx.p.wxApi.showToast(error)
}
}
})
},
/**平台商城支付 */
toPayOrder(e) {
wx.p.wxApi.showLoading()
const {
orderCode
} = e.currentTarget.dataset
wx.p.api.shopmallApi.platformGoodsPayOrder({
orderCode,
paymentSource: 1
}).then(res => {
wx.hideLoading()
if (res) {
const {
timeStamp,
nonceStr,
packages,
signType,
paySign
} = res.payParams
wx.requestPayment({
timeStamp: timeStamp,
nonceStr: nonceStr,
package: packages,
signType: signType,
paySign: paySign,
success() {
wx.p.router.go('/packageMine/pages/order/complete/complete', {
success: true
})
},
fail(res) {
if (res.errMsg == 'requestPayment:fail cancel') {
wx.p.wxApi.showToast('取消支付')
}
}
})
}
})
},
/**获取可申请的售后数量 */
getReturnCount(orderInfo) {
const PARAMS = {
subOrderCode: orderInfo.orderCode,
goodsSkuCode: orderInfo.orderGoods[0].goodsSkuCode
}
return wx.p.api.shopmallApi.platformApplyCount(PARAMS)
},
})
\ No newline at end of file \ No newline at end of file
{
"navigationStyle": "custom",
"usingComponents": {
"tab": "/components/Tab/Tab"
}
}
\ No newline at end of file \ No newline at end of file
/* packageMine/pages/order/index/index.wxss */
.sticky-box {
background-color: #fff;
}
.tab {
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: #fff;
z-index: 2;
transition: all 0.4s;
}
.navigation {
width: 100%;
height: 100%;
position: relative;
}
.navigation .back {
width: 64rpx;
height: 64rpx;
background: rgba(255, 255, 255, 0.5);
border-radius: var(--margin);
position: absolute;
left: 20rpx;
}
.navigation .back .icon {
width: 36rpx;
height: 36rpx;
}
.search-box {
position: absolute;
left: 80rpx;
width: 420rpx;
height: 72rpx;
background: #f7f8fa;
border-radius: 36rpx;
display: flex;
align-items: center;
box-sizing: border-box;
padding: 0 16rpx 0 var(--margin);
}
.search-box .icon {
width: 40rpx;
height: 100%;
}
.search-box .input {
width: calc(100% - 98rpx);
}
.search-box .clear-box {
width: 58rpx;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.search-box .clear-box .clear {
width: 32rpx;
height: 32rpx;
opacity: 0.7;
}
.placeholder-class {
color: #c8c9cc;
}
.layout {
padding: 24rpx var(--margin) 40rpx;
}
.layout .item {
position: relative;
padding-left: 24rpx;
margin-bottom: 20rpx;
background-color: #fff;
box-sizing: border-box;
border-radius: var(--borderRadius);
display: flex;
flex-direction: column;
}
.layout .item .top {
height: 82rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding-right: 24rpx;
position: relative;
}
.delivery-icon {
position: absolute;
width: 106rpx;
height: 80rpx;
left: 366rpx;
bottom: 0;
}
.layout .item .top .name {
width: 366rpx;
}
.layout .item .content-top {
border-top: 2rpx solid #eff0f2;
}
.layout .item .content {
border-top: 2rpx solid #eff0f2;
border-bottom: 2rpx solid #eff0f2;
}
.content-bottom {
border-bottom: 2rpx solid #eff0f2;
}
.layout .item .goods {
height: 208rpx;
padding: 24rpx 24rpx 24rpx 0;
box-sizing: border-box;
display: flex;
}
.addTo {
border-bottom: 2rpx solid #eff0f2;
}
.layout .item .goods .btn {
display: flex;
align-items: center;
justify-content: center;
width: 124rpx;
height: 46rpx;
border-radius: 25rpx;
border: 2rpx solid #b1b1b3;
font-size: 24rpx;
margin-left: 12rpx;
color: #656566;
position: absolute;
bottom: 0;
right: 0;
}
.layout .item .goods .confirm {
border-color: var(--btnColor);
color: var(--btnColor);
font-weight: 500;
}
.layout .item .icon {
width: 160rpx;
height: 160rpx;
margin-right: 20rpx;
border-radius: 8rpx;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.background-X {
background-color: rgb(244, 244, 244);
}
.layout .item .info {
width: calc(100% - 180rpx);
height: 160rpx;
display: flex;
flex-direction: column;
position: relative;
}
.layout .item .info .info-top,
.layout .item .info .info-bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.layout .item .info .info-top .price {
color: var(--btnColor);
font-size: 36rpx;
letter-spacing: -2rpx;
font-weight: 500;
flex-shrink: 0;
}
.layout .item .info .info-top .price .unit {
font-size: 24rpx;
}
.layout .item .info .info-bottom {
margin-top: 4rpx;
font-size: 24rpx;
color: #707071;
}
.layout .item .info .info-bottom .number {
margin-left: auto;
}
.layout .item .info .info-bottom .specification {
color: #b1b1b3;
}
.layout .item .status {
color: #b1b1b3;
font-size: 24rpx;
color: #282829;
}
.layout .item .bottom {
height: 80rpx;
display: flex;
align-items: center;
font-size: 24rpx;
color: #656566;
}
.layout .item .bottom .price {
color: var(--btnColor);
font-weight: 500;
}
.layout .item .btn-box {
position: absolute;
right: 24rpx;
bottom: 16rpx;
display: flex;
align-items: center;
justify-content: flex-end;
}
.layout .item .btn-box .btn {
display: flex;
align-items: center;
justify-content: center;
width: 124rpx;
height: 46rpx;
border-radius: 25rpx;
border: 2rpx solid #b1b1b3;
font-size: 24rpx;
margin-left: 12rpx;
color: #656566;
}
.layout .item .btn-box .pay {
background-color: var(--btnColor);
color: #fff;
border-color: var(--btnColor);
}
.layout .item .btn-box .empty{
color: var(--btnColor);
background-color: #fff;
}
.layout .item .btn-box .confirm {
border-color: var(--btnColor);
color: var(--btnColor);
font-weight: 500;
}
.userProfile {
background-color: #fff;
font-size: 24rpx;
margin: 0;
padding: 0;
font-weight: 500;
line-height: 46rpx;
}
.layout .coupon-item {
height: 202rpx;
background: #fefffe;
border-radius: 8rpx;
margin-bottom: 36rpx;
padding: 20rpx;
box-sizing: border-box;
position: relative;
}
.layout .coupon-item .orderPrices {
position: absolute;
color: var(--btnColor);
font-size: 48rpx;
right: 32rpx;
}
.layout .coupon-item .orderPrices text {
font-size: 36rpx;
}
.layout .coupon-item .icon {
width: 162rpx;
height: 162rpx;
margin-right: 20rpx;
}
.layout .coupon-item .info {
width: 360rpx;
height: 100%;
color: #b1b1b3;
font-size: 24rpx;
}
.layout .coupon-item .info .name {
font-size: 28rpx;
font-weight: 500;
color: #282829;
}
.layout .coupon-item .info .order-btn {
width: 138rpx;
height: 48rpx;
background: var(--btnColor);
border-radius: 24rpx;
margin-top: 40rpx;
color: #ffffff;
font-size: 24rpx;
}
.imageHeight {
height: 99rpx !important;
}
.imageStraight {
width: 92rpx;
height: 92rpx;
border-radius: 50%;
}
\ No newline at end of file \ No newline at end of file
<view class="sticky-box ">
<navigation-bar custom bindnavbarReady="navbarReady" page-title="我的订单">
<view class="navigation">
<view class="back text-center y-center" bindtap="back">
<glsx-image webp src="mall/back.png" class="icon"></glsx-image>
</view>
<view class="search-box y-center">
<view class="icon text-center">
<icon type="search" size="16"></icon>
</view>
<input type="text" placeholder="搜索" value="{{keyword}}" class="input" confirm-type="search" bindconfirm="search" bindinput="input" bindblur="blur" />
<block wx:if="{{keyword}}">
<view class="clear-box" bindtap="clear">
<view class="sprite-icon icon-clear"></view>
</view>
</block>
</view>
</view>
</navigation-bar>
<view class="tab" style="top:{{padding_bottom }}px;">
<tab tab="{{tab}}" bindclick="changeTab" index="{{tabIndex}}"></tab>
</view>
</view>
<block wx:if="{{margin_top}}">
<view class="layout isFullSucreen" style="margin-top:{{margin_top}}px;">
<block wx:if="{{listFlag}}">
<block wx:if="{{list.length}}">
<block wx:for="{{list}}" wx:key="index">
<!-- orderClassify 订单类型(1.订单;2:会员权益订单;3:门店服务订单;4:精品升级订单;5:平台商城订单) -->
<block wx:if="{{item.orderClassify == 1}}">
<view class="item" catchtap="jump" data-item="{{item}}">
<view class="top">
<view class="delivery-icon" wx:if="{{item.orderSource != 5}}">
<glsx-image webp src="mine/order/deliveryType-{{item.deliveryType}}.png">
</glsx-image>
</view>
<view class="name text-hide">{{item.merchantName}}</view>
<!-- 订单状态 orderStatus(1:待付款;2:已支付;3:已关闭;4:已发货;5:已收货;6:待发货;7:待安装;8:已安装;9:售后中;10:售后完成)
售后订单状态 afterSaleStatus(1:待审核;2:审核通过;3:审核不通过;4:待确认收到退货;5:退款中;6:已退款;7:退款失败)
-->
<view class="status">{{item.afterSaleStatus ? afterSaleStatus[item.afterSaleStatus]
:statusEnum[item.orderStatus]}}</view>
</view>
<view class="content-top {{item.orderStatus == 5 || item.orderStatus == 8?'':'content-bottom'}}">
<block wx:for="{{item.orderGoods}}" wx:for-item="i" wx:for-index="ind" wx:key="ind">
<view class="goods {{item.orderStatus == 5 || item.orderStatus == 8?'addTo':''}}">
<view class="icon">
<image webp wx:if="{{item.orderSource == 5}}" src="{{item.activityBigImg}}"></image>
<image webp wx:else src="{{i.goodsImage}}"></image>
</view>
<view class="info">
<view class="info-top">
<view class="name text-hide">{{item.orderSource == 5 ? item.activityName: i.goodsName}}</view>
<view class="price">
<text class="unit">¥</text>
{{item.orderSource == 5 ? item.payPrice: (i.activityPrice ||i.retailPrice)}}
</view>
</view>
<view class="info-bottom">
<block wx:if="{{i.specificationData}}">
<view class="specification">{{i.specificationData}}</view>
</block>
<view class="number">
x{{item.orderSource == 5 ? 1: i.goodsNumber}}
</view>
</view>
<view wx:if="{{item.orderGoods.length > 1}}">
<block wx:if="{{item.orderStatus == 5 || item.orderStatus == 8}}">
<block wx:if="{{item.evaluatedFlag == 'Y'}}">
<view class="btn confirm" catchtap="lookevaluate" data-item="{{item}}">查看评价</view>
</block>
<block wx:else>
<button catchtap="getUserProfile" wx:if="{{!hasUserInfo}}" class="btn confirm userProfile" data-item="{{item}}"> 立即评价 </button>
<view class="btn confirm" catchtap="evaluate" wx:else data-item="{{item}}">立即评价</view>
</block>
</block>
</view>
</view>
</view>
</block>
</view>
<view class="bottom" wx:if="{{item.orderSource == 5}}">
共1件商品,实付款<text class="price">¥{{item.payPrice}}</text>
</view>
<view class="bottom" wx:else>
共{{item.goodsNumber}}件商品,实付款<text class="price">¥{{item.payPrice}}</text>
</view>
<!-- 1:待付款;2:已支付;3:已关闭;4:已发货;5:已收货;6:待发货;7:待安装;8:已安装;9:售后中;10:售后完成 -->
<!-- 售后状态 1:待审核;2:审核通过;3:审核不通过;4:待确认收到退货;5:退款中;6:已退款;7:退款失败 -->
<block wx:if="{{item.orderStatus != 3}}">
<view class="btn-box">
<block wx:if="{{!item.afterSaleStatus}}">
<block wx:if="{{item.orderStatus == 1}}">
<view class="btn pay" catchtap="cancelPay" data-order-code="{{item.orderCode}}">取消付款</view>
<block wx:if="{{item.orderSource != 4}}">
<view class="btn pay" catchtap="pay" data-order-code="{{item.orderCode}}">去支付</view>
</block>
</block>
<block wx:if="{{item.orderSource==5 && (item.orderStatus == 2 || item.orderStatus == 7)}}">
<view class="btn pay" data-item="{{item}}" bind:tap="toGoldDetail">查看详情</view>
</block>
<block wx:elif="{{item.orderStatus > 2 && item.orderStatus < 9}}">
<!-- deliveryType 结算方式(1:到店核销,2:快递发货) -->
<block wx:if="{{item.deliveryType == 2 && item.orderStatus == 4}}">
<view class="btn confirm" catchtap="confirmReceipt" data-order-code="{{item.orderCode}}">确认收货
</view>
</block>
<block wx:if="{{item.payPrice > 0 && item.orderSource != 4}}">
<view class="btn" catchtap="afterSale" data-item="{{item}}" wx:if="{{!(item.relatedUserCouponStatus == 2 || item.relatedUserCouponStatus == 3)}}">申请售后
</view>
</block>
</block>
<view wx:if="{{item.orderGoods.length == 1}}">
<block wx:if="{{item.orderStatus == 5 || item.orderStatus == 8}}">
<block wx:if="{{item.evaluatedFlag == 'Y'}}">
<view class="btn confirm" catchtap="lookevaluate" data-item="{{item}}">查看评价</view>
</block>
<block wx:else>
<button catchtap="getUserProfile" wx:if="{{!hasUserInfo}}" class="btn confirm userProfile" data-item="{{item}}"> 立即评价 </button>
<view class="btn confirm" catchtap="evaluate" wx:else data-item="{{item}}">立即评价</view>
</block>
</block>
</view>
</block>
<block wx:else>
<block wx:if="{{item.afterSaleStatus == 1}}">
<view class="btn pay" catchtap="cancelOrder" data-order-code="{{item.orderCode}}">取消售后</view>
</block>
<view class="btn" data-item="{{item}}" catchtap="afterSaleDetail">售后详情</view>
</block>
</view>
</block>
</view>
</block>
<block wx:if="{{item.orderClassify == 2 || item.orderClassify == 3}}">
<view class="item" wx:for="{{item.orderGoods}}" wx:for-item="i" wx:for-index="ind" wx:key="ind">
<view class="top">
<!-- <view class="delivery-icon">
<image webp src="../../../images/{{item.orderType == 1?'exchange':'combo'}}.png"></image>
</view> -->
<view class="name text-hide" wx:if="{{item.orderClassify == 3}}">{{item.merchantName}}</view>
<view class="name text-hide" wx:if="{{item.orderClassify == 2}}">平台特供</view>
<!-- 套餐状态 -->
<view class="status" wx:if="{{item.orderClassify == 3 && item.equityOrderStatus !== 4}}">
{{cardStatus[item.equityOrderStatus]}}</view>
<view class="status" wx:if="{{item.orderClassify == 3 && item.equityOrderStatus == 4}}">
{{reStatus[item.equityOrderStatus]}}</view>
<!-- 直冲卡卷状态 -->
<view class="status" wx:if="{{i.appearance == 2}}">{{reStatus[item.equityOrderStatus]}}</view>
<view class="status" wx:if="{{i.appearance == 1 && item.equityOrderStatus !== 3}}">
{{cardStatus[item.equityOrderStatus]}}</view>
<view class="status" wx:if="{{i.appearance == 1 && item.equityOrderStatus == 3}}">已收货</view>
</view>
<view class="content">
<view class="goods">
<view class="icon background-X">
<!-- <image webp src="{{i.goodsImage}}"></image> -->
<glsx-image webp wx:if="{{item.orderClassify == 3}}" src="mine/order/combo.png"></glsx-image>
<image webp wx:else src="{{i.goodsImage}}" class="{{i.appearance == 1 ?'imageHeight':'imageStraight'}}"></image>
</view>
<view class="info">
<view class="info-top">
<view class="name text-hide">{{i.goodsName}}</view>
<view class="price">
<text class="unit">¥</text>
{{i.activityPrice ||i.retailPrice}}
</view>
</view>
<view class="info-bottom">
<view class="specification">
<view wx:if="{{i.appearance==1}}">质保期至 {{item.expiredTime}}</view>
<view wx:if="{{i.appearance == 2}}">充值账号:{{i.rechargeNumber || ''}}</view>
<view wx:if="{{i.appearance == 2}}">购买日期 {{item.time}}</view>
<view wx:if="{{item.orderClassify == 3&&i.appearance==null}}">{{i.specificationData}}</view>
</view>
</view>
</view>
</view>
</view>
<view class="bottom">
<view wx:if="{{i.appearance==2}}">订单编号 {{item.orderCode}}</view>
</view>
<view class="btn-box" wx:if="{{item.orderClassify == 2&&i.appearance == 1}}">
<view wx:if="{{item.equityOrderStatus==4 || item.equityOrderStatus==6}}" class="btn" data-item="{{item}}" bind:tap="toSaleDetailPage">售后详情</view>
<block wx:if="{{item.payPrice > 0 && item.orderSource != 4}}">
<view wx:if="{{item.equityOrderStatus==2}}" data-item="{{item}}" bind:tap="toSaleApplyPage" class="btn">申请售后</view>
</block>
<view wx:if="{{item.equityOrderStatus==2 || item.equityOrderStatus==4}}" data-item="{{item}}" bind:tap="toComfirmPage" class="btn confirm">确认收货</view>
<view wx:if="{{item.equityOrderStatus!=6}}" class="btn pay" data-item="{{item}}" bind:tap="toCheckCard">
查看卡券</view>
</view>
<view class="btn-box" wx:if="{{item.orderClassify==3}}">
<block wx:if="{{item.payPrice > 0 && item.orderSource != 4}}">
<view wx:if="{{item.orderClassify==3&&item.equityOrderStatus==2}}" data-item="{{item}}" bind:tap="toSaleApplyPackage" class="btn">申请售后</view>
</block>
<view wx:if="{{item.orderClassify==3&&item.equityOrderStatus==4}}" data-item="{{item}}" bind:tap="toPackageDetail" class="btn">售后详情</view>
<view wx:if="{{item.orderClassify==3&&item.equityOrderStatus!==4}}" class="btn pay" data-item="{{item}}" bind:tap="toCheckPackage">查看套餐</view>
</view>
</view>
</block>
<block wx:if="{{item.orderClassify == 4}}">
<view class="item">
<view class="top">
<view class="delivery-icon">
<glsx-image webp src="mine/order/boutique.png"></glsx-image>
</view>
<view class="name text-hide">{{item.merchantName}}</view>
</view>
<view class="content">
<view class="goods" wx:for="{{item.orderGoods}}" wx:for-item="i" wx:for-index="ind" wx:key="ind">
<view class="icon">
<!-- <image webp src="{{i.goodsImage}}"></image> -->
<image webp src="{{i.goodsImage}}"></image>
</view>
<view class="info">
<view class="info-top">
<view class="name text-hide">{{i.goodsName}}</view>
<view class="price">
<text class="unit">¥</text>
{{i.activityPrice ||i.retailPrice}}
</view>
</view>
<view class="info-bottom">
<block wx:if="{{i.specificationData}}">
<view class="specification">{{i.specificationData}}</view>
</block>
<view class="number">
x{{i.goodsNumber}}
</view>
</view>
</view>
</view>
</view>
<view class="bottom">
共{{item.goodsNumber}}件商品,实付款<text class="price">¥{{item.payPrice}}</text>
</view>
<view class="btn-box">
<view class="btn confirm" catchtap="boutiqueJump" data-order-code="{{item.orderCode}}">评价</view>
</view>
</view>
</block>
<block wx:if="{{item.orderClassify == 5}}">
<view class="item" catchtap="jumpPlatformShop" data-item="{{item}}" data-url="orderDetail/orderDetail">
<view class="top">
<view class="name text-hide">平台特供</view>
<!-- 订单状态 orderStatus(1:待付款;2:已支付;3:已关闭;4:已发货;5:已收货;6:待发货;7:待安装;8:已安装;9:售后中;10:售后完成)
售后订单状态 afterSaleStatus(1:待审核;2:审核通过;3:审核不通过;4:待确认收到退货;5:退款中;6:已退款;7:退款失败)
-->
<view class="status">{{item.afterSaleStatus ? afterSaleStatus[item.afterSaleStatus]
:statusEnum[item.orderStatus]}}</view>
</view>
<view class="content-top {{item.orderStatus == 5 || item.orderStatus == 8?'':'content-bottom'}}">
<block wx:for="{{item.orderGoods}}" wx:for-item="i" wx:for-index="ind" wx:key="ind">
<view class="goods {{item.orderStatus == 5 || item.orderStatus == 8?'addTo':''}}">
<view class="icon">
<image webp src="{{i.goodsImage}}"></image>
</view>
<view class="info">
<view class="info-top">
<view class="name text-hide">
<text>{{i.goodsName}}</text>
</view>
<view class="price">
<text class="unit">¥</text>
{{i.retailPrice}}
</view>
</view>
<view class="info-bottom">
<block wx:if="{{i.specificationData}}">
<view class="specification">{{i.specificationData}}</view>
</block>
<view class="number">
x{{i.goodsNumber}}
</view>
</view>
</view>
</view>
</block>
</view>
<view class="bottom" wx:if="{{item.orderSource == 5}}">
共1件商品,实付款<text class="price">¥{{item.payPrice}}</text>
</view>
<view class="bottom" wx:else>
共{{item.goodsNumber}}件商品,实付款<text class="price">¥{{item.payPrice}}</text>
</view>
<!-- 1:待付款;2:已支付;3:已关闭;4:已发货;5:已收货;6:待发货;7:待安装;8:已安装;9:售后中;10:售后完成 -->
<!-- 售后状态 1:待审核;2:审核通过;3:审核不通过;4:待确认收到退货;5:退款中;6:已退款;7:退款失败 -->
<block wx:if="{{item.orderStatus != 3}}">
<view class="btn-box">
<block wx:if="{{!item.afterSaleStatus}}">
<block wx:if="{{item.orderStatus == 1}}">
<view class="btn" catchtap="cancelPlatformOrder" data-order-code="{{item.orderCode}}">取消订单</view>
<view class="btn pay empty" catchtap="toPayOrder" data-order-code="{{item.mainOrderCode}}">立即支付</view>
</block>
<block wx:elif="{{item.orderStatus > 2 && item.orderStatus < 9}}">
<block wx:if="{{item.orderStatus != 6 }}">
<view class="btn confirm" catchtap="jumpPlatformShop" data-item="{{item}}" data-url="orderDetail/orderDetail">查看物流
</view>
</block>
<block wx:if="{{item.platformOrderStatus == 1008 || item.platformOrderStatus == 1009}}">
<view class="btn" catchtap="jumpPlatformShop" data-item="{{item}}" data-url="applySale/index">售后
</view>
</block>
</block>
</block>
<block wx:else>
<view class="btn" catchtap="jumpPlatformShop" data-item="{{item}}" data-url="afterSaleDetail/index">售后</view>
</block>
</view>
</block>
</view>
</block>
</block>
<block wx:if="{{nothing}}">
<view class="list-nothing to-bottom"></view>
</block>
</block>
<block wx:else>
<view class="list-nothing">
暂无相关内容
</view>
</block>
</block>
</view>
</block>
\ No newline at end of file \ No newline at end of file
...@@ -29,6 +29,9 @@ Page({ ...@@ -29,6 +29,9 @@ Page({
wx.p.storage.set('userInfo', data) wx.p.storage.set('userInfo', data)
wx.p.storage.set('sessionId', data.sessionId) wx.p.storage.set('sessionId', data.sessionId)
if (!data) throw message if (!data) throw message
} else {
wx.p.storage.rm('userInfo')
wx.p.storage.rm('sessionId')
} }
console.log(data, '=============') console.log(data, '=============')
//scenc获取页面参数并跳转 //scenc获取页面参数并跳转
......
...@@ -44,7 +44,7 @@ Component({ ...@@ -44,7 +44,7 @@ Component({
methods: { methods: {
jump(e) { jump(e) {
let { id } = e.currentTarget.dataset let { id } = e.currentTarget.dataset
wx.p.router.go('/packageShopmall/packageMall/pages/detail/detail', { id, isActivity: true, notIntercept: true }) wx.p.router.go('/packageMall/pages/detail/detail', { id, isActivity: true, notIntercept: true })
}, },
countDown(params) { countDown(params) {
params.forEach(v => { params.forEach(v => {
......
@import "/style/common.wxss"; @import "/assets/style/common.wxss";
.Activity { .Activity {
display: flex; display: flex;
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
.item-box-price .now { .item-box-price .now {
font-size: 40rpx; font-size: 40rpx;
color: #FF6038; color: var(--btnColor);
font-weight: 600; font-weight: 600;
} }
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
border-radius: 0 8rpx 8rpx 8rpx; border-radius: 0 8rpx 8rpx 8rpx;
margin-top: 14rpx; margin-top: 14rpx;
font-size: 20rpx; font-size: 20rpx;
color: #FF6038; color: var(--btnColor);
display: flex; display: flex;
} }
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
} }
.time.end { .time.end {
color: #FA2C18; color:var(--btnColor);
} }
.time.start { .time.start {
...@@ -164,5 +164,5 @@ ...@@ -164,5 +164,5 @@
} }
.time.end .time-content { .time.end .time-content {
background: #FA2C18; background: var(--btnColor);
} }
\ No newline at end of file \ No newline at end of file
// components/banner/banner.js
Component({
/**
* 组件的属性列表
*/
properties: {
customerlist: {
type: Array,
value: []
},
show: Boolean
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
showFlex() {
this.setData({
show: false
})
},
// 保存客服企微二维码
saveClick() {
const [item] = this.data.customerlist
if (!item || !item.qrCode) return
wx.getSetting({
success(res) {
wx.downloadFile({
url: item.qrCode,
success: function (res) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function (data) {
wx.showToast({
title: "保存成功",
icon: "success",
duration: 2000
});
},
fail: function (err) {
console.log(err);
},
complete(res) {
console.log(res);
}
});
}
});
}
});
}
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {
},
"component": true
}
\ No newline at end of file \ No newline at end of file
<block wx:if="{{show}}">
<view class="model" catchtouchmove="noScroll">
<view class="bgkf">
<glsx-image webp src="home/home-kf-bg.png"></glsx-image>
<view class="close-icon" bindtap="showFlex">
<glsx-image webp src="home/kf-close.png"></glsx-image>
</view>
<view class="qr-box">
<view class="userinfo-wrap">
<view class="icon">
<image wx:if="{{customerlist[0].thumbAvatar}}" webp src="{{customerlist[0].thumbAvatar}}"></image>
<glsx-image wx:else webp src="home/kf-persion-icon.png"></glsx-image>
</view>
<view class="name">{{customerlist[0].staffName || ''}}</view>
<view class="mobile" wx:if="{{customerlist[0].staffPhone}}">
<glsx-image webp src="home/kf-mobile.png"></glsx-image>
<text>{{customerlist[0].staffPhone}}</text>
</view>
<view class="qr-icon">
<glsx-image webp src="home/home-kf-qr-bg.png"></glsx-image>
<view class="qr-code">
<image webp src="{{customerlist[0].qrCode}}" show-menu-by-longpress="{{customerlist[0].qrCode}}"></image>
</view>
</view>
</view>
</view>
<view class="kf-text">
<view class="text-left"><glsx-image webp src="home/home-Kf-down.png"></glsx-image><text>保存图片\n到相册</text></view>
<view><glsx-image webp src="home/home-Kf-phone.png"></glsx-image><text>打开微信扫一扫添加客服企微</text></view>
</view>
<view class="save-btn">
<view class="btn text-center" bindtap="saveClick">
保存
</view>
</view>
</view>
</view>
</block>
.model {
position: fixed;
left: 0;
right: 0;
top: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
width: 100%;
height: 100%;
z-index: 999999;
}
.close-icon{
width:48rpx;
height:48rpx;
position: absolute;
right: 16rpx;
top: -68rpx;
}
.close-icon image{
width:48rpx;
height:48rpx;
}
.model .bgkf {
width: 600rpx;
height: 700rpx;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
z-index: 99999;
}
.model .qr-box {
height: 560rpx;
width: 100%;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 0;
}
.model .bgkf .icon {
width: 104rpx;
height: 104rpx;
border-radius: 50%;
position: absolute;
top: -28rpx;
}
.model .bgkf .icon image {
border-radius: 50%;
}
.userinfo-wrap {
display: flex;
align-items: center;
flex-direction: column
}
.qr-box .text {
font-size: 32rpx;
font-weight: 500;
color: #282829;
line-height: 44rpx;
}
.qr-box .name {
font-size: 36rpx;
font-weight: 500;
color: #282829;
line-height: 50rpx;
margin: 80rpx 0 0 0;
text-align: center;
}
.qr-box .mobile{
font-size: 32rpx;
font-weight: 500;
line-height: 44rpx;
display: inline-flex;
justify-content: center;
align-items: center;
margin-bottom: 20rpx;
}
.qr-box .mobile image{
width: 24rpx;
height: 26rpx;
}
.qr-box .qr-icon {
width: 284rpx;
height: 284rpx;
position: relative;
}
.qr-box .qr-code {
width: 220rpx;
height: 220rpx;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.kf-text{
width:100%;
height:140rpx;
position: absolute;
bottom: 0;
z-index: 999998;
display: flex;
background: #F7F8FA;
border-radius: 0 0 10px 10px;
padding: 0 40rpx;
box-sizing: border-box;
}
.kf-text view{
flex: 1;
display: flex;
align-items: center;
justify-content: left;
font-weight: 400;
font-size: 12px;
margin-left: 20rpx;
color: #B1B1B3;
}
.kf-text image{
flex-shrink: 0;
width: 60rpx;
height: 60rpx;
margin-right: 12rpx;
}
.save-btn{
display: flex;
align-items: center;
justify-content: center;
margin-top: 32rpx;
}
.save-btn .btn{
width: 420rpx;
height: 80rpx;
background: var(--btnColor);
border-radius: 8rpx;
}
.save-btn .btn.text-center{
text-align: center;
line-height: 80rpx;
color: #ffffff;
font-size: 28rpx;
}
\ No newline at end of file \ No newline at end of file
...@@ -84,7 +84,7 @@ Component({ ...@@ -84,7 +84,7 @@ Component({
if (item.classifyName && item.classifyName == '秒杀') { if (item.classifyName && item.classifyName == '秒杀') {
isActivity = true isActivity = true
} }
wx.p.router.go('/packageShopmall/packageMall/pages/detail/detail', { wx.p.router.go('/packageMall/pages/detail/detail', {
id, id,
isActivity, isActivity,
notIntercept: true notIntercept: true
......
<wxs module="fn"> <wxs module="fn">
module.exports = { module.exports = {
priceFilter: function(e, num) { priceFilter: function (e, num) {
return e.toString().split('.')[num] || '' return e.toString().split('.')[num] || ''
} }
} }
</wxs> </wxs>
<view class="Goods"> <view class="Goods">
<view class="left"> <view class="left">
<block <block wx:for="{{list}}" wx:for-index="idx" wx:key="idx" wx:for-item="item">
wx:for="{{list}}" <template is="item" data="{{item}}" wx:if="{{idx%2==0}}" />
wx:for-index="idx" </block>
wx:key="idx" </view>
wx:for-item="item"> <view class="right">
<template is="item" data="{{item}}" wx:if="{{idx%2==0}}" /> <block wx:for="{{list}}" wx:for-index="idx" wx:key="idx" wx:for-item="item">
</block> <template is="item" data="{{item}}" wx:if="{{idx%2==1}}" />
</view> </block>
<view class="right"> </view>
<block <template name="item">
wx:for="{{list}}" <view class='item-box' wx:if="{{item.goods}}" bindtap='jump' data-item="{{item}}">
wx:for-index="idx" <view class="preview">
wx:key="idx" <image webp src="{{item.goods.goodsImage}}" lazy-load></image>
wx:for-item="item"> </view>
<template is="item" data="{{item}}" wx:if="{{idx%2==1}}" /> <view class="item-box-content">
</block> <view class='item-box-title'>
</view> <image wx:if="{{item.goods.isMemberGoods}}" webp src="{{item.IMGURL}}index/member-goods-icon.png" />
<template name="item"> <text>{{item.goods.goodsName}}</text>
<view </view>
class='item-box' <view class='item-box-time'>
wx:if="{{item.goods}}" <view class="text text-hide">
bindtap='jump' {{item.goodsStatistics.viewAmount||0}}人查看|售出{{item.goodsStatistics.saleAmount || 0}}
data-item="{{item}}"> </view>
<view class="preview"> </view>
<image webp src="{{item.goods.goodsImage}}" lazy-load></image> <view class="item-box-price">
</view> <view class="now">
<view class="item-box-content"> <text class="unit">¥</text>
<view class='item-box-title'> <text>{{fn.priceFilter(item.goods.retailPrice || 0, 0)}}.</text>
<image wx:if="{{item.goods.isMemberGoods}}" webp src="{{item.IMGURL}}index/member-goods-icon.png" /> <text class="price-last">{{fn.priceFilter(item.goods.retailPrice || 0, 1)}}</text>
<text>{{item.goods.goodsName}}</text> <text class="unit up" wx:if="{{item.unit}}">{{item.unit}}</text>
</view> <text class="unit up" wx:if="{{item.up}}">起</text>
<view class='item-box-time'> </view>
<view class="text text-hide"> <block wx:if="{{item.goods.originalPrice >= 0 && item.goods.originalPrice}}">
{{item.goodsStatistics.viewAmount||0}}人查看|售出{{item.goodsStatistics.saleAmount || 0}} <view class="old">¥{{item.goods.originalPrice || 0}}</view>
</view> </block>
</view> </view>
<view class="item-box-price"> <view class="item-box-bubble">
<view class="now"> <!-- 会员商品 -->
<text class="unit">¥</text> <view wx:if="{{item.goods.isMemberGoods}}" class="text">
<text>{{fn.priceFilter(item.goods.retailPrice || 0, 0)}}.</text> <text>会员价</text>
<text class="price-last">{{fn.priceFilter(item.goods.retailPrice || 0, 1)}}</text> 开通会员权益立享
<text class="unit up" wx:if="{{item.unit}}">{{item.unit}}</text> </view>
<text class="unit up" wx:if="{{item.up}}">起</text> </view>
</view> <view class="item-box-goods-label">
<block wx:if="{{item.goods.originalPrice >= 0 && item.goods.originalPrice}}"> <view wx:if="{{item.goods.relatedCoupon}}" class="coupon-logotype">
<view class="old">¥{{item.goods.originalPrice || 0}}</view> <text wx:if="{{item.goods.relatedCoupon}}" class="coupon-logo">券</text>
</block> <text class="coupon-name">{{item.goods.relatedCoupon.couponName}}</text>
</view> </view>
<view class="item-box-bubble"> <view wx:if="{{item.goods.freeShipping}}" class="free-shipping">包邮</view>
<!-- 会员商品 --> </view>
<view wx:if="{{item.goods.isMemberGoods}}" class="text"> </view>
<text>会员价</text> </view>
开通会员权益立享 </template>
</view> </view>
</view>
<view class="item-box-goods-label">
<view wx:if="{{item.goods.relatedCoupon}}" class="coupon-logotype">
<text wx:if="{{item.goods.relatedCoupon}}" class="coupon-logo">券</text>
<text class="coupon-name">{{item.goods.relatedCoupon.couponName}}</text>
</view>
<view wx:if="{{item.goods.freeShipping}}" class="free-shipping">包邮</view>
</view>
</view>
</view>
</template>
</view>
\ No newline at end of file \ No newline at end of file
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
.item-box-price .now{ .item-box-price .now{
font-size: 40rpx; font-size: 40rpx;
color: #FF6038; color: var(--btnColor);
font-weight: 600; font-weight: 600;
} }
......
...@@ -10,8 +10,7 @@ Component({ ...@@ -10,8 +10,7 @@ Component({
data: {}, data: {},
lifetimes: { lifetimes: {
ready() { ready() {
// this.getMerchantDetail() this.getMerchantDetail()
this.toCheckMember()
} }
}, },
/** /**
...@@ -19,40 +18,16 @@ Component({ ...@@ -19,40 +18,16 @@ Component({
*/ */
methods: { methods: {
getMerchantDetail() { getMerchantDetail() {
const merchantId = wx.$storage.get('srcm_shopmall_merchant_id') const {
mineApi merchantId
.getMerchantDetail() } = wx.p.storage.get('merchant_info')
.then(data => { wx.p.api.mineApi.getMerchantDetail({
if (data.bussinessBegintime) { merchantId
data.bussinessBegintime = data.bussinessBegintime.split(':')[0] + ':' + data.bussinessBegintime.split(':')[1] }).then(data => {
} this.setData({
if (data.bussinessEndtime) { merchantDetail: data
data.bussinessEndtime = data.bussinessEndtime.split(':')[0] + ':' + data.bussinessEndtime.split(':')[1]
}
this.setData({
merchantDetail: data
})
this.getConsultantInfo()
}) })
}, this.toCheckMember()
// 获取当前用户服务顾问
getConsultantInfo() {
let merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
if (merchantId) {
merchantId = Number(JSON.parse(merchantId))
}
let data = {
merchantId: merchantId
}
mineApi.getConsultantInfo(data).then(({
code,
data
}) => {
if (code == '0') {
this.setData({
consultant: data
})
}
}) })
}, },
// 获取用户会员信息 // 获取用户会员信息
...@@ -95,9 +70,7 @@ Component({ ...@@ -95,9 +70,7 @@ Component({
}) })
}, },
toBuyMember() { toBuyMember() {
wx.navigateTo({ wx.p.router.go('/packageEquity/pages/open/open')
url: '/packageShopmall/packageEquity/pages/open/open'
})
} }
} }
}) })
\ No newline at end of file \ No newline at end of file
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<view class="store-img"> <view class="store-img">
<glsx-image src="home/store-icon.png"></glsx-image> <glsx-image src="home/store-icon.png"></glsx-image>
</view> </view>
<view class="store-name">海马刀酒类旗舰店</view> <view class="store-name">{{merchantDetail.merchantName}}</view>
<view class="store-phone" bindtap="callPhone"> <view class="store-phone" bindtap="callPhone">
<glsx-image src="home/store-phone.png"></glsx-image> <glsx-image src="home/store-phone.png" ></glsx-image>
</view> </view>
</view> </view>
<view class="equity-box"> <view class="equity-box">
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
display: flex; display: flex;
z-index: 2; z-index: 2;
align-items: center; align-items: center;
position: relative;
} }
.store-img { .store-img {
...@@ -29,9 +30,12 @@ ...@@ -29,9 +30,12 @@
} }
.store-phone { .store-phone {
margin-left: auto; position: absolute;
width: 56rpx; right: 16rpx;
height: 56rpx; top: 50%;
transform: translateY(-50%);
width: 80rpx;
height: 104rpx;
} }
.equity-box { .equity-box {
......
import {
kfMixin,
} from '~/mixins/index'
Page({ Page({
// behaviors: [kfMixin], behaviors: [kfMixin],
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
...@@ -121,6 +124,7 @@ Page({ ...@@ -121,6 +124,7 @@ Page({
noticeContent, noticeContent,
bannerList bannerList
}) })
this.filterKfList(data)
}) })
}, },
changeTab(e) { changeTab(e) {
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
"banner": "./components/banner/banner", "banner": "./components/banner/banner",
"good-tab": "./components/good-tab/good-tab", "good-tab": "./components/good-tab/good-tab",
"goods": "./components/goods/goods", "goods": "./components/goods/goods",
"activity": "./components/activity/activity" "activity": "./components/activity/activity",
"customer": "./components/customer/customer"
}, },
"navigationStyle": "custom", "navigationStyle": "custom",
"onReachBottomDistance": 10, "onReachBottomDistance": 10,
......
...@@ -77,14 +77,12 @@ page { ...@@ -77,14 +77,12 @@ page {
padding: 10rpx 0; padding: 10rpx 0;
} }
.back-to-top { .wx {
background: #fff;
border-radius: 50%;
position: fixed; position: fixed;
right: 24rpx; right: 0;
bottom: 245rpx; bottom: 245rpx;
width: 60rpx; width: 96rpx;
height: 60rpx; height: 96rpx;
z-index: 100; z-index: 100;
} }
......
...@@ -72,10 +72,10 @@ ...@@ -72,10 +72,10 @@
</view> </view>
</block> </block>
</block> </block>
<view class="back-to-top {{scrollToTop ? 'show-top': 'hidden-top'}}" bindtap="backTop"> <view class="wx" bindtap="openKF">
<image webp src="{{IMGURL}}index/back-to-top.png"></image> <glsx-image webp src="home/wx.png"></glsx-image>
</view> </view>
</view> </view>
</block> </block>
<!-- 客服 --> <!-- 客服 -->
<customer show="{{widgetStatus}}" customerlist="{{customerlist}}" bindclose="closeCustomer"></customer>
\ No newline at end of file \ No newline at end of file
<customer model:show="{{widgetStatus}}" customerlist="{{customerlist}}"></customer>
\ No newline at end of file \ No newline at end of file
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
.Goods .price .old { .Goods .price .old {
color: #C9CACC; color: #C9CACC;
text-decoration: line-through; text-decoration: line-through;
margin-left: 8rpx; margin-left: auto;
} }
.text-hide { .text-hide {
......
...@@ -17,6 +17,14 @@ Page({ ...@@ -17,6 +17,14 @@ Page({
navHeight: height, navHeight: height,
}) })
}, },
search(e) {
let value = e.detail
let { goodsList } = this.data
wx.$router.go('/packageMall/pages/search/search', {
value,
goodsList
})
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
......
...@@ -39,17 +39,10 @@ Component({ ...@@ -39,17 +39,10 @@ Component({
*/ */
methods: { methods: {
goOrder(e) { goOrder(e) {
let userInfo = wx.$util.getUserInfo() let tabIndex = e.currentTarget.dataset.key + 1
if (userInfo) { wx.p.router.go('/packageMine/pages/order/index/index',{
let index = e.currentTarget.dataset.key + 1 tabIndex
wx.navigateTo({ })
url: '/packageShopmall/packageMine/pages/order/index/index?tabIndex=' + (index || '')
})
} else {
wx.navigateTo({
url: '/pages/Login/Login'
})
}
} }
} }
}) })
\ No newline at end of file \ No newline at end of file
...@@ -5,8 +5,7 @@ Page({ ...@@ -5,8 +5,7 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
toolList: [ toolList: [{
{
text: '购物车', text: '购物车',
icon: 'myShopping', icon: 'myShopping',
url: '/packageMall/pages/shoppingCart/shoppingCart' url: '/packageMall/pages/shoppingCart/shoppingCart'
...@@ -23,7 +22,12 @@ Page({ ...@@ -23,7 +22,12 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
let {
userInfo
} = this.data
if (userInfo) {
this.getOrderNumberList()
}
}, },
navbarReady(e) { navbarReady(e) {
let { let {
...@@ -36,13 +40,22 @@ Page({ ...@@ -36,13 +40,22 @@ Page({
login() { login() {
wx.p.router.go('/pages/Login/Login') wx.p.router.go('/pages/Login/Login')
}, },
goSetUp(){ goSetUp() {
wx.p.router.go('/packageMine/pages/setting/index') wx.p.router.go('/packageMine/pages/setting/index')
}, },
jump(e){ jump(e) {
const {url} = e.currentTarget.dataset const {
url
} = e.currentTarget.dataset
wx.p.router.go(url) wx.p.router.go(url)
}, },
getOrderNumberList() {
wx.p.api.mineApi.getOrderNumberList().then(res => {
this.setData({
orderNumberList: [res.unPayCount, res.unShippedCount, res.unReceivedCount, res.unServiceCount]
})
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
......
<view class="navigation-bar"> <view class="navigation-bar">
<navigation-bar navStyle="background-color: transparent;" bindnavbarReady="navbarReady" page-title="个人中心">个人中心</navigation-bar> <navigation-bar navStyle="background-color: transparent;" bindnavbarReady="navbarReady" page-title="会员中心">会员中心</navigation-bar>
</view> </view>
<block wx:if="{{user_box_style}}"> <block wx:if="{{user_box_style}}">
<view class="layout mine"> <view class="layout mine">
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</block> </block>
</view> </view>
<!-- 我的券包 --> <!-- 我的券包 -->
<view class="coupon-box box flex"> <view class="coupon-box box flex" bindtap="jump" data-url="/packageMine/pages/coupon/index/index">
我的卡券 我的卡券
<view class="icon"> <view class="icon">
<glsx-image src="mine/mine-arrow.png"></glsx-image> <glsx-image src="mine/mine-arrow.png"></glsx-image>
......
...@@ -9,11 +9,15 @@ class RouterBefore { ...@@ -9,11 +9,15 @@ class RouterBefore {
onShow = thisPage.onShow onShow = thisPage.onShow
thisPage.onLoad = function () { thisPage.onLoad = function () {
const event = getApp().globalData.ROUTE_QUERY const event = getApp().globalData.ROUTE_QUERY
const userInfo = wx.p.storage.get('userInfo')
let options = { let options = {
...event, ...event,
...arguments[0] ...arguments[0]
} }
getApp().globalData.ROUTE_QUERY = {} getApp().globalData.ROUTE_QUERY = {}
this.setData({
userInfo
})
onLoad && onLoad.apply(this, [options]), (this.options = options) onLoad && onLoad.apply(this, [options]), (this.options = options)
} }
thisPage.onShow = function () { thisPage.onShow = function () {
......
import getAppId from '~/utils/utils_wx'
// 图片cdn 加速使用地址
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd/'
// 缓存get方法为空的默认指定值 // 缓存get方法为空的默认指定值
export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo'] export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
export const appId = getAppId.getAppId()
// 缓存get方法key的对应才映射值 // 缓存get方法key的对应才映射值
export const STORAGE_OBJECTkEY = { export const STORAGE_OBJECTkEY = {
system_info: 'system_info', system_info: 'system_info',
...@@ -19,15 +13,7 @@ export const STORAGE_OBJECTkEY = { ...@@ -19,15 +13,7 @@ export const STORAGE_OBJECTkEY = {
unauthorized:'unauthorized' unauthorized:'unauthorized'
} }
// 图片版本号
export const IMG_VERSION = async () => {
const accountInfo = await wx.p.util.getMockData()
return accountInfo?.version || Date.now()
}
export default{ export default{
IMG_URL,
DEFAULT_GET_STORAGEKEY, DEFAULT_GET_STORAGEKEY,
STORAGE_OBJECTkEY, STORAGE_OBJECTkEY
IMG_VERSION
} }
\ No newline at end of file \ No newline at end of file
import { dsnUrl } from '~/config' import { dsnUrl } from "~/config";
import * as Sentry from '~/utils/lib/sentry-miniapp' import { Sentry } from "~/lib/index";
export default function sentryInit() { export default function sentryInit() {
// accountInfo.miniProgram.envVersion == 'release' && // accountInfo.miniProgram.envVersion == 'release' &&
const accountInfo = wx.getAccountInfoSync() const accountInfo = wx.getAccountInfoSync();
//测试和生产才开发sentry //测试和生产才开发sentry
const env = ['trial', 'release'] const env = ["trial", "release"];
env.includes(accountInfo.miniProgram.envVersion) && env.includes(accountInfo.miniProgram.envVersion) &&
Sentry.init({ Sentry.init({
// dsn: 'http://ebcf31c417cc4ce185782f046e4a87a2@sentry.glsx.com.cn/5' // dsn: 'http://ebcf31c417cc4ce185782f046e4a87a2@sentry.glsx.com.cn/5'
dsn: dsnUrl dsn: dsnUrl,
}) });
} }
import api from '~/api/request/http'
/** /**
* 日期格式化 * 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') //log 2020-07-31 10:00:00 * let time = new Date().format('yyyy-MM-dd hh:mm:ss') //log 2020-07-31 10:00:00
...@@ -127,44 +126,6 @@ const parseString = str => { ...@@ -127,44 +126,6 @@ const parseString = str => {
return obj return obj
} }
/**获取mock数据 */
let mockRequestCount = null,
mockTimer = {},
mockCache = null
const getMockData = async () => {
const MOCKDATA = wx.p.storage.get('mock_data')
try {
if (MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
return Promise.resolve(MOCKDATA)
} else {
if (!mockRequestCount) {
mockCache = null
mockRequestCount = Date.now()
const data = await api.getMock()
data.createTime = Date.now()
mockCache = data
wx.p.storage.set('mock_data', data)
return Promise.resolve(data)
} else {
const key = Date.now()
return new Promise((resolve) => {
mockTimer[key] = setInterval(() => {
if (mockCache) {
clearInterval(mockTimer[key])
mockRequestCount = null
resolve(mockCache)
}
}, 1e3)
})
}
}
} catch (error) {
if (mockTimer[key]) clearInterval(mockTimer[key])
mockRequestCount = null
return Promise.reject(error)
}
}
const Util = { const Util = {
onReachBottom, onReachBottom,
isFullSucreen, isFullSucreen,
...@@ -172,6 +133,5 @@ const Util = { ...@@ -172,6 +133,5 @@ const Util = {
throttle, throttle,
isEmptyObj, isEmptyObj,
parseString, parseString,
getMockData
} }
export default Util export default Util
import wxqrcode from '~/lib/wxqrcode.js' import {wxqrcode} from '~/lib/index.js'
/** /**
* 禁止滑动 * 禁止滑动
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!