Compare commits

...

6 Commits
master ... ymf

31 changed files with 9859 additions and 6587 deletions

259
App.vue
View File

@ -25,141 +25,143 @@ App.vue本身不是页面这里不能编写视图元素也就是没有<tem
uni.hideTabBar() uni.hideTabBar()
//#ifdef APP-PLUS //#ifdef APP-PLUS
// //
plus.runtime.getProperty(plus.runtime.appid, widgetInfo => { // plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
// // //
console.log("widgetInfo==",widgetInfo) // console.log("widgetInfo==",widgetInfo)
getFindBySource({source:'点餐宝'}).then(res => { // getFindBySource({source:''}).then(res => {
if (res.url && widgetInfo.version < res.version) { // if (res.url && widgetInfo.version < res.version) {
let downloadLink = res.url; // let downloadLink = res.url;
console.log(downloadLink) // console.log(downloadLink)
let ready = false; // let ready = false;
// // //
if (res.isUp == 1) { // if (res.isUp == 1) {
uni.showModal({ // uni.showModal({
showCancel: false, // showCancel: false,
title: '发现新版本', // title: '',
confirmText: '立即更新', // confirmText: '',
content: res.message, // content: res.message,
success: res => { // success: res => {
if (res.confirm) { // if (res.confirm) {
uni.showLoading({title:'下载中...'}); // uni.showLoading({title:'...'});
if (uni.getSystemInfoSync().platform == // if (uni.getSystemInfoSync().platform ==
'android') { // 'android') {
uni.hideLoading() // uni.hideLoading()
uni.downloadFile({ // uni.downloadFile({
url: downloadLink, // url: downloadLink,
success: downloadResult => { // success: downloadResult => {
uni.hideLoading() // uni.hideLoading()
if (downloadResult.statusCode === 200) { // if (downloadResult.statusCode === 200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => { // plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
entry.getParent(_oldFile=>{ // entry.getParent(_oldFile=>{
entry.moveTo(_oldFile,'.apk',newFilePath=>{ // entry.moveTo(_oldFile,'.apk',newFilePath=>{
console.log('newFilePath',newFilePath.fullPath) // console.log('newFilePath',newFilePath.fullPath)
plus.runtime // plus.runtime
.install(newFilePath.fullPath, { force: false }, // .install(newFilePath.fullPath, { force: false },
d => { // d => {
console // console
.log( // .log(
'install success...' // 'install success...'
); // );
plus.runtime // plus.runtime
.restart(); // .restart();
}, // },
e => { // e => {
console.log(e) // console.log(e)
console // console
.error( // .error(
'install fail...' // 'install fail...'
); // );
} // }
); // );
}) // })
}) // })
}) // })
} // }
} // }
}); // });
} // }
if (uni.getSystemInfoSync().platform == // if (uni.getSystemInfoSync().platform ==
'ios') { // 'ios') {
plus.runtime.openURL(downloadLink, function( // plus.runtime.openURL(downloadLink, function(
res) {}); // res) {});
} // }
} else if (res.cancel) { // } else if (res.cancel) {
console.log('取消'); // console.log('');
} // }
} // }
}); // });
} else { // } else {
uni.showModal({ // uni.showModal({
title: '发现新版本', // title: '',
confirmText: '立即更新', // confirmText: '',
cancelText: '下次更新', // cancelText: '',
content: res.message, // content: res.message,
success: res => { // success: res => {
if (res.confirm) { // if (res.confirm) {
uni.showLoading({title:'下载中...'}); // uni.showLoading({title:'...'});
if (uni.getSystemInfoSync().platform == // if (uni.getSystemInfoSync().platform ==
'android') { // 'android') {
uni.downloadFile({ // uni.downloadFile({
url: downloadLink, // url: downloadLink,
success: downloadResult => { // success: downloadResult => {
if (downloadResult // if (downloadResult
.statusCode === // .statusCode ===
200) { // 200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => { // plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
entry.getParent(_oldFile=>{ // entry.getParent(_oldFile=>{
entry.moveTo(_oldFile,'.apk',newFilePath=>{ // entry.moveTo(_oldFile,'.apk',newFilePath=>{
console.log('newFilePath',newFilePath.fullPath) // console.log('newFilePath',newFilePath.fullPath)
plus.runtime // plus.runtime
.install(newFilePath.fullPath, { force: false }, // .install(newFilePath.fullPath, { force: false },
d => { // d => {
console // console
.log( // .log(
'install success...' // 'install success...'
); // );
plus.runtime // plus.runtime
.restart(); // .restart();
}, // },
e => { // e => {
console.log(e) // console.log(e)
console // console
.error( // .error(
'install fail...' // 'install fail...'
); // );
} // }
); // );
}) // })
}) // })
}) // })
} // }
} // }
}); // });
} // }
if (uni.getSystemInfoSync().platform == // if (uni.getSystemInfoSync().platform ==
'ios') { // 'ios') {
plus.runtime.openURL(downloadLink, function( // plus.runtime.openURL(downloadLink, function(
res) {}); // res) {});
} // }
} else if (res.cancel) { // } else if (res.cancel) {
uni.hideLoading() // uni.hideLoading()
console.log('取消'); // console.log('');
} // }
} // }
}); // });
} // }
} // }
}).catch((res)=>{ // }).catch((res)=>{
console.log(res) // console.log(res)
}) // })
}); // });
// #endif // #endif
}); });
</script> </script>
<style lang="scss"> <style lang="scss">
@import "uview-plus/index.scss";
/** 每个页面公共css */ /** 每个页面公共css */
@import '@/commons/style/common.scss'; @import '@/commons/style/common.scss';
@import '@/commons/style/ipad.scss'; @import '@/commons/style/ipad.scss';
@ -167,5 +169,4 @@ App.vue本身不是页面这里不能编写视图元素也就是没有<tem
/** uni 组件样式覆盖 */ /** uni 组件样式覆盖 */
@import '@/commons/style/uni-overwrite.scss'; @import '@/commons/style/uni-overwrite.scss';
@import "uview-plus/index.scss";
</style> </style>

View File

@ -404,3 +404,12 @@ text {
::v-deep .u-m-t-16 .u-textarea{ ::v-deep .u-m-t-16 .u-textarea{
border-width: 1px!important; border-width: 1px!important;
} }
/* #ifdef H5 */
.u-flex, .u-flex-row, .u-flex-x, .up-flex, .up-flex-row, .up-flex-x{
// flex-direction: row;
}
/* #endif */
.u-flex-col{
flex-direction: column!important;
}

View File

@ -1,72 +0,0 @@
/**
* 加解密工具包
*
* @author terrfly
* @site https://www.jeepay.vip
* @date 2021/5/16 17:35
*/
import { SM4 } from 'gm-crypto'
import appConfig from '@/config/appConfig.js'
let HEX_KEY = null
// 字符串转16进制
function str2hex(str) {
var val = ''
for (var i = 0; i < str.length; i++) {
if (val == '')
val = str.charCodeAt(i).toString(16)
else
val += str.charCodeAt(i).toString(16)
}
val += ''
return val
}
// 获取hex秘钥
function getHexKey(){
if(!HEX_KEY){
HEX_KEY = str2hex(appConfig.encryptKey)
}
return HEX_KEY
}
// 解密 (http响应数据 做通用处理)
export function sm4DecryptByResData(data){
if(!data){
return data
}
let res = SM4.decrypt(data, getHexKey(), {
inputEncoding: 'base64',
outputEncoding: 'utf8'
})
if(!res){
return res
}
return JSON.parse(res)['originData']
}
// 加密 (http响应数据 做通用处理)
export function sm4EncryptByReqData(data){
if(!data){
return data
}
// 加密处理
let encryptData = SM4.encrypt(JSON.stringify(data), getHexKey(), {
inputEncoding: 'utf8',
outputEncoding: 'base64'
})
return {encryptData : encryptData}
}

View File

@ -11,19 +11,19 @@
</view> </view>
<template v-if="accountType.sel==1"> <template v-if="accountType.sel==1">
<up-form-item prop="merchantName"> <up-form-item prop="merchantName">
<up--input v-model="vdata.formData.merchantName" placeholder="请输入商户号"> <up-input v-model="vdata.formData.merchantName" placeholder="请输入商户号">
</up--input> </up-input>
</up-form-item> </up-form-item>
</template> </template>
<up-form-item prop="username"> <up-form-item prop="username">
<up--input v-model="vdata.formData.username" placeholder="请输入登录名/手机号"></up--input> <up-input v-model="vdata.formData.username" placeholder="请输入登录名/手机号"></up-input>
</up-form-item> </up-form-item>
<up-form-item prop="pwd"> <up-form-item prop="pwd">
<up--input v-model="vdata.formData.pwd" type="password" placeholder="请输入登录密码"></up--input> <up-input v-model="vdata.formData.pwd" type="password" placeholder="请输入登录密码"></up-input>
</up-form-item> </up-form-item>
<up-form-item prop="code"> <up-form-item prop="code">
<up--input v-model="vdata.formData.code" placeholder="请输入验证码"> <up-input v-model="vdata.formData.code" placeholder="请输入验证码">
</up--input> </up-input>
<image :src="vdata.formData.img" class=" " style="width: 100px; height: 40px;margin-left: 5px;" <image :src="vdata.formData.img" class=" " style="width: 100px; height: 40px;margin-left: 5px;"
@click="getCode" mode=""> @click="getCode" mode="">
</image> </image>
@ -94,9 +94,6 @@
</template> </template>
<script setup> <script setup>
import {
encrypt
} from '@/commons/utils/rsaEncrypt.js'
import { import {
ref, ref,

View File

@ -8,7 +8,7 @@ const appConfig = {
// 环境变量相关 // 环境变量相关
env: {}, env: {},
wss: "ws://192.168.1.42:2348", // wss: "ws://192.168.1.42:2348", // ws://192.168.1.42:2348
// wss: "wss://sockets.sxczgkj.com/wss", // // wss: "wss://sockets.sxczgkj.com/wss", //
// 环境变量常量 // 环境变量常量
ENV_ENUM: { ENV_ENUM: {

View File

@ -10,7 +10,6 @@
// 导入全局属性 // 导入全局属性
import appConfig from '@/config/appConfig.js' import appConfig from '@/config/appConfig.js'
import storageManage from '@/commons/utils/storageManage.js' import storageManage from '@/commons/utils/storageManage.js'
import { sm4DecryptByResData } from '@/commons/utils/encryptUtil.js'
import infoBox from "@/commons/utils/infoBox.js" import infoBox from "@/commons/utils/infoBox.js"
import go from '@/commons/utils/go.js'; import go from '@/commons/utils/go.js';
let baseUrl = 'http://192.168.1.42' let baseUrl = 'http://192.168.1.42'
@ -95,11 +94,6 @@ function commonsProcess(showLoading, httpReqCallback){
return Promise.reject(bodyData) return Promise.reject(bodyData)
} }
// 加密数据
if(!bodyData.data && bodyData.encryptData){
return Promise.resolve({ bizData: sm4DecryptByResData(bodyData.encryptData), code: bodyData.code })
}
// 构造请求成功的响应数据 // 构造请求成功的响应数据
return Promise.resolve({ bizData: bodyData.data, code: bodyData.code }) return Promise.resolve({ bizData: bodyData.data, code: bodyData.code })

View File

@ -10,9 +10,6 @@
// 导入全局属性 // 导入全局属性
import appConfig from '@/config/appConfig.js' import appConfig from '@/config/appConfig.js'
import storageManage from '@/commons/utils/storageManage.js' import storageManage from '@/commons/utils/storageManage.js'
import {
sm4DecryptByResData
} from '@/commons/utils/encryptUtil.js'
import infoBox from "@/commons/utils/infoBox.js" import infoBox from "@/commons/utils/infoBox.js"
import go from '@/commons/utils/go.js'; import go from '@/commons/utils/go.js';
let baseUrl = 'http://101.37.12.135:8080' let baseUrl = 'http://101.37.12.135:8080'
@ -99,14 +96,6 @@ function commonsProcess(showLoading, httpReqCallback) {
return Promise.reject(bodyData) return Promise.reject(bodyData)
} }
// 加密数据
if (!bodyData.data && bodyData.encryptData) {
return Promise.resolve({
bizData: sm4DecryptByResData(bodyData.encryptData),
code: bodyData.code
})
}
// 构造请求成功的响应数据 // 构造请求成功的响应数据
return Promise.resolve({ return Promise.resolve({

View File

@ -1,11 +1,6 @@
// 代课下单 // 代课下单
import http from './http.js' import http from './http.js'
import $API from '@/http/classApi.js' import { accountUrl, marketUrl } from './prveUrl.js'
import appConfig from '@/config/appConfig.js'
import {
Base64
} from 'js-base64'
import infoBox from '@/commons/utils/infoBox.js'
const request = http.request const request = http.request
@ -360,10 +355,10 @@ export function $returnOrder(data) {
}); });
} }
//获取订单可用优惠券 //获取用户可用优惠券
export function $activateByOrderId(data) { export function $findCoupon(data) {
return request({ return request({
url: '/api/tbShopCoupon/activateByOrderId', url: marketUrl+'/admin/coupon/findCoupon',
method: "get", method: "get",
params: { params: {
shopId: uni.getStorageSync("shopId"), shopId: uni.getStorageSync("shopId"),

View File

@ -1,5 +1,6 @@
import http from './http.js' import http from './http.js'
const request=http.request const request=http.request
import {accountUrl} from './prveUrl.js'
/** /**
@ -8,7 +9,7 @@ const request=http.request
*/ */
export function getTbShopCoupon(data) { export function getTbShopCoupon(data) {
return request({ return request({
url: `/api/tbShopCoupon`, url:accountUrl+ `/admin/coupon/findCoupon`,
method: 'get', method: 'get',
params: { params: {
shopId: uni.getStorageSync('shopId'), shopId: uni.getStorageSync('shopId'),

View File

@ -10,9 +10,6 @@
// 导入全局属性 // 导入全局属性
import appConfig from '@/config/appConfig.js' import appConfig from '@/config/appConfig.js'
import storageManage from '@/commons/utils/storageManage.js' import storageManage from '@/commons/utils/storageManage.js'
import {
sm4DecryptByResData
} from '@/commons/utils/encryptUtil.js'
import infoBox from "@/commons/utils/infoBox.js" import infoBox from "@/commons/utils/infoBox.js"
import go from '@/commons/utils/go.js'; import go from '@/commons/utils/go.js';
import { import {
@ -30,7 +27,7 @@ import {
// let baseUrl = 'https://cashier.sxczgkj.com' // let baseUrl = 'https://cashier.sxczgkj.com'
// 本地测 // 本地测
let baseUrl = "http://192.168.1.31" let baseUrl = "http://192.168.1.42"
// #ifdef H5 // #ifdef H5
baseUrl = '/ysk' baseUrl = '/ysk'
// #endif // #endif
@ -110,17 +107,6 @@ function commonsProcess(showLoading, httpReqCallback) {
return Promise.reject(bodyData) // 跳转到catch函数 return Promise.reject(bodyData) // 跳转到catch函数
} }
// 加密数据
if (!bodyData.data && bodyData.encryptData) {
return Promise.resolve({
bizData: sm4DecryptByResData(bodyData.encryptData),
code: bodyData.code
})
}
// 构造请求成功的响应数据 // 构造请求成功的响应数据
return Promise.resolve(bodyData) return Promise.resolve(bodyData)

View File

@ -0,0 +1,19 @@
import http from './http.js'
const request = http.request
import {marketUrl} from './prveUrl.js'
/**
* 限时折扣
* @returns
*/
export function limitTimeDiscount(params) {
return request({
url: marketUrl+`/admin/limitTimeDiscount`,
method: 'get',
params: {
shopId: uni.getStorageSync('shopId'),
...params
}
})
}

View File

@ -0,0 +1,19 @@
import http from '../http.js'
const request = http.request
import {marketUrl} from '../prveUrl.js'
/**
* 限时折扣
* @returns
*/
export function getDiscountByUserId(params) {
return request({
url: marketUrl+`/admin/consumeDiscount/getDiscountByUserId`,
method: 'get',
params: {
shopId: uni.getStorageSync('shopId'),
...params
}
})
}

View File

@ -1,5 +1,6 @@
import http from './http.js' import http from './http.js'
const request = http.request const request = http.request
import {orderUrl} from './prveUrl.js'
/** /**
* 查询订单 * 查询订单
@ -49,7 +50,7 @@ export function createOrder(data, urlType = 'order') {
*/ */
export function tbOrderInfoDetail(id) { export function tbOrderInfoDetail(id) {
return request({ return request({
url: `/api/tbOrderInfo/${id}`, url: orderUrl+ `/admin/order/historyOrder?orderId=${id}`,
method: "get" method: "get"
}); });
} }

3
http/yskApi/prveUrl.js Normal file
View File

@ -0,0 +1,3 @@
export const marketUrl = '/market'
export const accountUrl = '/account'
export const orderUrl = '/order'

View File

@ -1,11 +1,7 @@
// 用户管理 // 用户管理
import http from './http.js' import http from './http.js'
import $API from '@/http/classApi.js' import {accountUrl} from './prveUrl.js'
import appConfig from '@/config/appConfig.js'
import {
Base64
} from 'js-base64'
import infoBox from '@/commons/utils/infoBox.js'
const request=http.request const request=http.request
@ -23,7 +19,7 @@ export function getwxacode(data) {
*/ */
export function queryAllShopUser(params) { export function queryAllShopUser(params) {
return request({ return request({
url: `/api/tbShopUser/queryAllShopUser`, url: accountUrl+`/admin/shopUser`,
method: "get", method: "get",
params: { params: {
shopId: uni.getStorageSync('shopId'), shopId: uni.getStorageSync('shopId'),
@ -46,3 +42,18 @@ export function queryAllShopInfo(params) {
} }
}); });
} }
/**
* 获取店铺用户详情
* @returns
*/
export function shopUserDetail(params) {
return request({
url: accountUrl+`/admin/shopUser/detail`,
method: "get",
params: {
shopId: uni.getStorageSync('shopId'),
...params
}
});
}

77
package-lock.json generated
View File

@ -5,6 +5,7 @@
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {
"bignumber.js": "^9.3.1",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"gm-crypto": "^0.1.8", "gm-crypto": "^0.1.8",
@ -12,7 +13,8 @@
"js-base64": "^3.7.2", "js-base64": "^3.7.2",
"jsencrypt": "^3.3.2", "jsencrypt": "^3.3.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"uview-plus": "^3.3.32" "uview-plus": "^3.3.32",
"ysk-utils": "^1.0.53"
}, },
"devDependencies": { "devDependencies": {
"copy-webpack-plugin": "^12.0.2", "copy-webpack-plugin": "^12.0.2",
@ -20,18 +22,6 @@
"sass-loader": "^10.5.2" "sass-loader": "^10.5.2"
} }
}, },
"node_modules/@babel/runtime": {
"version": "7.27.0",
"resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.27.0.tgz",
"integrity": "sha512-VtPOkrdPHZsKc/clNqyi9WUA8TINkZ4cGk63UUE3u4pmB2k+ZMQRDuIOagv8UVd6j7k0T3+RRIb7beKTebNbcw==",
"license": "MIT",
"dependencies": {
"regenerator-runtime": "^0.14.0"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@jridgewell/gen-mapping": { "node_modules/@jridgewell/gen-mapping": {
"version": "0.3.8", "version": "0.3.8",
"resolved": "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", "resolved": "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz",
@ -490,6 +480,15 @@
"node": "*" "node": "*"
} }
}, },
"node_modules/bignumber.js": {
"version": "9.3.1",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz",
"integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==",
"license": "MIT",
"engines": {
"node": "*"
}
},
"node_modules/binary-extensions": { "node_modules/binary-extensions": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz", "resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz",
@ -666,18 +665,6 @@
"license": "MIT", "license": "MIT",
"peer": true "peer": true
}, },
"node_modules/copy-text-to-clipboard": {
"version": "3.2.0",
"resolved": "https://registry.npmmirror.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.0.tgz",
"integrity": "sha512-RnJFp1XR/LOBDckxTib5Qjr/PMfkatD0MUCQgdpqS8MdKiNUzBjAQBEN6oUy+jW7LI93BBG3DtMB2KOOKpGs2Q==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/copy-webpack-plugin": { "node_modules/copy-webpack-plugin": {
"version": "12.0.2", "version": "12.0.2",
"resolved": "https://registry.npmmirror.com/copy-webpack-plugin/-/copy-webpack-plugin-12.0.2.tgz", "resolved": "https://registry.npmmirror.com/copy-webpack-plugin/-/copy-webpack-plugin-12.0.2.tgz",
@ -702,17 +689,6 @@
"webpack": "^5.1.0" "webpack": "^5.1.0"
} }
}, },
"node_modules/core-js": {
"version": "3.41.0",
"resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.41.0.tgz",
"integrity": "sha512-SJ4/EHwS36QMJd6h/Rg+GyR4A5xE0FSI3eZ+iBVpfqf1x0eTSg1smWLHrA+2jQThZSh97fmSgFSU8B61nxosxA==",
"hasInstallScript": true,
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"node_modules/dayjs": { "node_modules/dayjs": {
"version": "1.11.13", "version": "1.11.13",
"resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.13.tgz", "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.13.tgz",
@ -1154,6 +1130,13 @@
"node": ">=8.9.0" "node": ">=8.9.0"
} }
}, },
"node_modules/loadsh": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/loadsh/-/loadsh-0.0.4.tgz",
"integrity": "sha512-U+wLL8InpfRalWrr+0SuhWgGt10M4OyAk6G8xCYo2rwpiHtxZkWiFpjei0vO463ghW8LPCdhqQxXlMy2qicAEw==",
"deprecated": "This is a typosquat on the popular Lodash package. This is not maintained nor is the original Lodash package.",
"license": "MIT"
},
"node_modules/lodash": { "node_modules/lodash": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz", "resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz",
@ -1214,11 +1197,6 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/mutation-observer": {
"version": "1.0.3",
"resolved": "https://registry.npmmirror.com/mutation-observer/-/mutation-observer-1.0.3.tgz",
"integrity": "sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA=="
},
"node_modules/neo-async": { "node_modules/neo-async": {
"version": "2.6.2", "version": "2.6.2",
"resolved": "https://registry.npmmirror.com/neo-async/-/neo-async-2.6.2.tgz", "resolved": "https://registry.npmmirror.com/neo-async/-/neo-async-2.6.2.tgz",
@ -1324,12 +1302,6 @@
"node": ">=8.10.0" "node": ">=8.10.0"
} }
}, },
"node_modules/regenerator-runtime": {
"version": "0.14.1",
"resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
"integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==",
"license": "MIT"
},
"node_modules/require-from-string": { "node_modules/require-from-string": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmmirror.com/require-from-string/-/require-from-string-2.0.2.tgz", "resolved": "https://registry.npmmirror.com/require-from-string/-/require-from-string-2.0.2.tgz",
@ -1837,6 +1809,17 @@
"engines": { "engines": {
"node": ">=10.13.0" "node": ">=10.13.0"
} }
},
"node_modules/ysk-utils": {
"version": "1.0.54",
"resolved": "https://registry.npmjs.org/ysk-utils/-/ysk-utils-1.0.54.tgz",
"integrity": "sha512-uIqi+Z/LPiwZvGF2kiJ2Oc+6a6qOQPbViAHrQHP/LchBplAdQqW1ePl9lgBSnS7Hu4u1fxdblerF+AfmfOOdSA==",
"license": "ISC",
"dependencies": {
"bignumber.js": "^9.3.1",
"loadsh": "^0.0.4",
"lodash": "^4.17.21"
}
} }
} }
} }

View File

@ -1,5 +1,6 @@
{ {
"dependencies": { "dependencies": {
"bignumber.js": "^9.3.1",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"gm-crypto": "^0.1.8", "gm-crypto": "^0.1.8",
@ -7,7 +8,8 @@
"js-base64": "^3.7.2", "js-base64": "^3.7.2",
"jsencrypt": "^3.3.2", "jsencrypt": "^3.3.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"uview-plus": "^3.3.32" "uview-plus": "^3.3.32",
"ysk-utils": "^1.0.56"
}, },
"devDependencies": { "devDependencies": {
"copy-webpack-plugin": "^12.0.2", "copy-webpack-plugin": "^12.0.2",

View File

@ -1,25 +1,19 @@
<template> <template>
<view class="login-wrapper"> <view class="login-wrapper">
<view class="login-top"> <view class="login-top">
<text>欢迎回来请登录</text> <text>欢迎回来请登录</text>
<image @tap="envChangeTipsRef.tapFunc()" style="width: 320rpx; height: 76rpx" <image @tap="envChangeTipsRef.tapFunc()" style="width: 320rpx; height: 76rpx" :src="vdata.siteInfos.appTopImgUrl" />
:src="vdata.siteInfos.appTopImgUrl" />
</view> </view>
<view class="login-bottom jeepay-form"> <view class="login-bottom jeepay-form">
<!-- 不需要label, 需要修改 label-width="0" --> <!-- 不需要label, 需要修改 label-width="0" -->
<uni-forms ref="loginFormRef" label-width="0" :model="vdata.formData" :rules="rules"> <uni-forms ref="loginFormRef" label-width="0" :model="vdata.formData" :rules="rules">
<view class="u-p-b-30"> <view class="u-p-b-30">
<my-tabs size="large" @change="accountTypeChange" v-model="accountType.sel" :list="accountType.list" <my-tabs size="large" @change="accountTypeChange" v-model="accountType.sel" :list="accountType.list" textKey="label"></my-tabs>
textKey="label"></my-tabs>
</view> </view>
<view v-if="vdata.loginType == 'pwd'"> <view v-if="vdata.loginType == 'pwd'">
<template v-if="accountType.sel == 1"> <template v-if="accountType.sel == 1">
<uni-forms-item name="merchantName"> <uni-forms-item name="merchantName">
<uni-easyinput class='jeepay-easyinput' placeholder="请输入商户号" <uni-easyinput class="jeepay-easyinput" placeholder="请输入商户号" v-model="vdata.formData.merchantName" :clearable="false">
v-model="vdata.formData.merchantName" :clearable="false">
<template #prefixIcon> <template #prefixIcon>
<image src="@/static/login/icon-user.svg" class="input-icon" /> <image src="@/static/login/icon-user.svg" class="input-icon" />
</template> </template>
@ -28,8 +22,7 @@
</template> </template>
<uni-forms-item name="username"> <uni-forms-item name="username">
<uni-easyinput class='jeepay-easyinput' placeholder="请输入登录名/手机号" <uni-easyinput class="jeepay-easyinput" placeholder="请输入登录名/手机号" v-model="vdata.formData.username" :clearable="false">
v-model="vdata.formData.username" :clearable="false">
<template #prefixIcon> <template #prefixIcon>
<image src="@/static/login/icon-user.svg" class="input-icon" /> <image src="@/static/login/icon-user.svg" class="input-icon" />
</template> </template>
@ -37,13 +30,18 @@
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="pwd"> <uni-forms-item name="pwd">
<uni-easyinput class='jeepay-easyinput' :type="vdata.isShowPwd ? 'text' : 'password'" <uni-easyinput
v-model="vdata.formData.pwd" :clearable="false" placeholder="请输入登录密码"> class="jeepay-easyinput"
:type="vdata.isShowPwd ? 'text' : 'password'"
v-model="vdata.formData.pwd"
:clearable="false"
placeholder="请输入登录密码"
>
<template #prefixIcon> <template #prefixIcon>
<image src="@/static/login/icon-pw.svg" class="input-icon" /> <image src="@/static/login/icon-pw.svg" class="input-icon" />
</template> </template>
<template #suffixIcon> <template #suffixIcon>
<view class='show-tips' @tap="vdata.isShowPwd = !vdata.isShowPwd "> <view class="show-tips" @tap="vdata.isShowPwd = !vdata.isShowPwd">
{{ vdata.isShowPwd ? '隐藏' : '显示' }} {{ vdata.isShowPwd ? '隐藏' : '显示' }}
</view> </view>
</template> </template>
@ -52,60 +50,57 @@
<uni-forms-item name="code"> <uni-forms-item name="code">
<!-- 手机验证码 不限制数字还是本文 如果发送为文本则无需app升级 --> <!-- 手机验证码 不限制数字还是本文 如果发送为文本则无需app升级 -->
<view style="display: flex;" class="u-flex u-flex-y-center"> <view style="display: flex" class="u-flex u-flex-y-center">
<uni-easyinput class='jeepay-easyinput' :maxlength="6" placeholder="请输入验证码" <uni-easyinput class="jeepay-easyinput" :maxlength="6" placeholder="请输入验证码" v-model="vdata.formData.code" :clearable="false">
v-model="vdata.formData.code" :clearable="false">
<template #prefixIcon> <template #prefixIcon>
<image src="@/static/login/icon-sms-code.svg" class="input-icon" /> <image src="@/static/login/icon-sms-code.svg" class="input-icon" />
</template> </template>
</uni-easyinput> </uni-easyinput>
<image :src="vdata.formData.img" class=" u-m-b-50" <image :src="vdata.formData.img" class="u-m-b-50" style="width: 200rpx; height: 80rpx; margin-left: 10rpx" @click="getCode" mode=""></image>
style="width: 200rpx; height: 80rpx;margin-left: 10rpx;" @click="getCode" mode="">
</image>
</view> </view>
</uni-forms-item> </uni-forms-item>
</view> </view>
<view v-if="vdata.loginType == 'sms'"> <view v-if="vdata.loginType == 'sms'">
<uni-forms-item name="loginPhone"> <uni-forms-item name="loginPhone">
<uni-easyinput class='jeepay-easyinput' v-model="vdata.formData.loginPhone" type="number" <uni-easyinput
:maxlength="11" :disabled="!vdata.allowSendMsgFlag" placeholder="请输入手机号" :clearable="false"> class="jeepay-easyinput"
v-model="vdata.formData.loginPhone"
type="number"
:maxlength="11"
:disabled="!vdata.allowSendMsgFlag"
placeholder="请输入手机号"
:clearable="false"
>
<template #prefixIcon> <template #prefixIcon>
<image src="@/static/login/icon-phone.svg" class="input-icon" /> <image src="@/static/login/icon-phone.svg" class="input-icon" />
</template> </template>
<template #suffixIcon> <template #suffixIcon>
<view class='show-tips' @tap="sendSmscodeFunc">{{ vdata.sendMsgText }}</view> <view class="show-tips" @tap="sendSmscodeFunc">{{ vdata.sendMsgText }}</view>
</template> </template>
</uni-easyinput> </uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item> <uni-forms-item>
<!-- 手机验证码 不限制数字还是本文 如果发送为文本则无需app升级 --> <!-- 手机验证码 不限制数字还是本文 如果发送为文本则无需app升级 -->
<view style="display: flex;"> <view style="display: flex">
<uni-easyinput class='jeepay-easyinput' :maxlength="6" placeholder="请输入验证码" <uni-easyinput class="jeepay-easyinput" :maxlength="6" placeholder="请输入验证码" v-model="vdata.formData.vercode" :clearable="false">
v-model="vdata.formData.vercode" :clearable="false">
<template #prefixIcon> <template #prefixIcon>
<image src="@/static/login/icon-sms-code.svg" class="input-icon" /> <image src="@/static/login/icon-sms-code.svg" class="input-icon" />
</template> </template>
</uni-easyinput> </uni-easyinput>
<image :src="vdata.formData.imgCodeUrl" <image :src="vdata.formData.imgCodeUrl" style="width: 200rpx; height: 110rpx; margin-left: 10rpx" @click="getCode" mode=""></image>
style="width: 200rpx; height: 110rpx;margin-left: 10rpx;" @click="getCode" mode="">
</image>
</view> </view>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="smsCode"> <uni-forms-item name="smsCode">
<!-- 手机验证码 不限制数字还是本文 如果发送为文本则无需app升级 --> <!-- 手机验证码 不限制数字还是本文 如果发送为文本则无需app升级 -->
<uni-easyinput class='jeepay-easyinput' :maxlength="6" placeholder="请输入手机验证码" <uni-easyinput class="jeepay-easyinput" :maxlength="6" placeholder="请输入手机验证码" v-model="vdata.formData.smsCode" :clearable="false">
v-model="vdata.formData.smsCode" :clearable="false">
<template #prefixIcon> <template #prefixIcon>
<image src="@/static/login/icon-sms-code.svg" class="input-icon" /> <image src="@/static/login/icon-sms-code.svg" class="input-icon" />
</template> </template>
</uni-easyinput> </uni-easyinput>
</uni-forms-item> </uni-forms-item>
</view> </view>
</uni-forms> </uni-forms>
<!-- <view class="agreement-policy"> <!-- <view class="agreement-policy">
@ -116,7 +111,6 @@
<text class="policy" @click="toPrivacy">隐私政策</text> <text class="policy" @click="toPrivacy">隐私政策</text>
</view> --> </view> -->
<!-- <view class="agreement-policy"> <!-- <view class="agreement-policy">
<JeepayCheckbox v-model:checked="vdata.isSelectedAgreement" /> <JeepayCheckbox v-model:checked="vdata.isSelectedAgreement" />
同意 同意
@ -126,7 +120,6 @@
<text class="policy" @click="go.to('PAGES_STATIC_POLICY')">隐私政策</text> <text class="policy" @click="go.to('PAGES_STATIC_POLICY')">隐私政策</text>
</view> --> </view> -->
<Button @tap="loginFunc">登录</Button> <Button @tap="loginFunc">登录</Button>
<!-- <view class="register-box"> <!-- <view class="register-box">
@ -139,92 +132,67 @@
{{ vdata.loginType == 'pwd' ? '短信验证码登录' : '账号密码登录' }} {{ vdata.loginType == 'pwd' ? '短信验证码登录' : '账号密码登录' }}
<image src="@/static/login/icon-arrow-left.svg"></image> <image src="@/static/login/icon-arrow-left.svg"></image>
</view> --> </view> -->
</view> </view>
</view> </view>
<JAgree service="PAGES_STATIC_AGREEMENT" privacy="PAGES_FORGET_PASSWORD" ref="refAgr" <JAgree service="PAGES_STATIC_AGREEMENT" privacy="PAGES_FORGET_PASSWORD" ref="refAgr" @agree="vdata.isSelectedAgreement = true" />
@agree="vdata.isSelectedAgreement = true" />
</template> </template>
<script setup> <script setup>
import {
encrypt
} from '@/commons/utils/rsaEncrypt.js'
import { import { ref, reactive, onMounted, watch } from 'vue';
ref, import { $loginByPwd, $phoneCodeLogin, $userInfo, $sendSms, $getSiteInfos, $getUploadImgSize, $isCode } from '@/http/apiManager.js';
reactive, import storageManage from '@/commons/utils/storageManage.js';
onMounted,
watch
} from 'vue';
import {
$loginByPwd,
$phoneCodeLogin,
$userInfo,
$sendSms,
$getSiteInfos,
$getUploadImgSize,
$isCode
} from '@/http/apiManager.js';
import storageManage from '@/commons/utils/storageManage.js'
import infoBox from '@/commons/utils/infoBox.js'; import infoBox from '@/commons/utils/infoBox.js';
import go from '@/commons/utils/go.js' import go from '@/commons/utils/go.js';
import timer from '@/commons/utils/timer.js' import timer from '@/commons/utils/timer.js';
import formUtil from '@/commons/utils/formUtil.js' import formUtil from '@/commons/utils/formUtil.js';
import Button from '@/components/Button/Button.vue' import Button from '@/components/Button/Button.vue';
import { import { getExtStoreId } from '@/commons/utils/versionManage.js';
getExtStoreId import { $login } from '@/http/newApi/login.js';
} from "@/commons/utils/versionManage.js" import { login, getCodeImg } from '@/http/yskApi/login.js';
import {
$login
} from '@/http/newApi/login.js';
import {
login,
getCodeImg
} from '@/http/yskApi/login.js';
const accountType = reactive({ const accountType = reactive({
list: [{ list: [
{
label: '商户', label: '商户',
value: '0' value: '0'
}, },
{ {
label: '员工', label: '员工',
value: '1' value: '1'
}, }
], ],
sel: 0 sel: 0
}) });
const loginFormRef = ref() const loginFormRef = ref();
const envChangeTipsRef = ref() const envChangeTipsRef = ref();
const refAgr = ref() const refAgr = ref();
const rules = { const rules = {
merchantName: { merchantName: {
rules: [formUtil.rules.requiredInputShowToast('商户号')], rules: [formUtil.rules.requiredInputShowToast('商户号')]
}, },
username: { username: {
rules: [formUtil.rules.requiredInputShowToast('用户名')], rules: [formUtil.rules.requiredInputShowToast('用户名')]
}, },
pwd: { pwd: {
rules: [formUtil.rules.requiredInputShowToast('密码')], rules: [formUtil.rules.requiredInputShowToast('密码')]
}, },
safetyCode: { safetyCode: {
rules: [formUtil.rules.requiredInputShowToast('安全码')], rules: [formUtil.rules.requiredInputShowToast('安全码')]
}, },
code: { code: {
rules: [formUtil.rules.requiredInputShowToast('验证码')], rules: [formUtil.rules.requiredInputShowToast('验证码')]
}, },
loginPhone: { loginPhone: {
rules: [formUtil.rules.requiredInputShowToast('手机号')], rules: [formUtil.rules.requiredInputShowToast('手机号')]
}, },
smsCode: { smsCode: {
rules: [formUtil.rules.requiredInputShowToast('短信验证码')], rules: [formUtil.rules.requiredInputShowToast('短信验证码')]
},
} }
};
const vdata = reactive({ const vdata = reactive({
isShowPwd: false, // isShowPwd: false, //
loginType: 'pwd', // pwd or sms loginType: 'pwd', // pwd or sms
isShowSafetyCode: false, // isShowSafetyCode: false, //
@ -242,12 +210,11 @@
uuid: '', uuid: '',
merchantName: '', merchantName: '',
loginType: 'merchant' loginType: 'merchant'
}, }
});
})
// #ifdef H5 // #ifdef H5
vdata.formData.username = 'xpc' vdata.formData.username = 'xpc';
vdata.formData.pwd = '123' vdata.formData.pwd = '123';
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// vdata.formData.username = '15699991111' // vdata.formData.username = '15699991111'
@ -257,23 +224,29 @@
function accountTypeChange(e) { function accountTypeChange(e) {
// #ifdef H5 // #ifdef H5
if (e == 1) { if (e == 1) {
vdata.formData.merchantName = '18049104914' vdata.formData.merchantName = '18049104914';
vdata.formData.username = '13666666666' vdata.formData.username = '13666666666';
vdata.formData.pwd = '123456' vdata.formData.pwd = '123456';
} else { } else {
vdata.formData.pwd = 'qwer1234' vdata.formData.pwd = 'qwer1234';
} }
// #endif // #endif
} }
const getCode = () => { const getCode = async () => {
getCodeImg().then(res => { try {
vdata.formData.img = res.data.code const res = await getCodeImg();
vdata.formData.uuid = res.data.uuid vdata.formData.img = res.data.code;
}) vdata.formData.uuid = res.data.uuid;
} catch (error) {
uni.showToast({
title: error.message,
icon: 'none'
});
} }
};
getCode() getCode();
onMounted(() => { onMounted(() => {
// getExtStoreId() // getExtStoreId()
@ -286,12 +259,12 @@
// }) // })
// } // }
// , // ,
let info = uni.getStorageSync('MerchantId') let info = uni.getStorageSync('MerchantId');
if (info.merchantName) { if (info.merchantName) {
vdata.formData.merchantName = info.merchantName vdata.formData.merchantName = info.merchantName;
vdata.formData.username = info.username vdata.formData.username = info.username;
} }
}) });
// //
function changeLoginType() { function changeLoginType() {
@ -306,7 +279,8 @@
// return false // return false
// } // }
let loginPromise = null; let loginPromise = null;
if (vdata.loginType == 'pwd') { // if (vdata.loginType == 'pwd') {
//
// loginPromise = $loginByPwd(vdata.formData.username, vdata.formData.pwd, vdata.formData.safetyCode) // loginPromise = $loginByPwd(vdata.formData.username, vdata.formData.pwd, vdata.formData.safetyCode)
loginPromise = login({ loginPromise = login({
username: vdata.formData.username, username: vdata.formData.username,
@ -317,35 +291,35 @@
uuid: vdata.formData.uuid, uuid: vdata.formData.uuid,
merchantName: vdata.formData.merchantName, merchantName: vdata.formData.merchantName,
loginType: accountType.list[accountType.sel].value loginType: accountType.list[accountType.sel].value
}) });
} else if (vdata.loginType == 'sms') {
} else if (vdata.loginType == 'sms') { // //
loginPromise = $phoneCodeLogin(vdata.formData.loginPhone, vdata.formData.smsCode) loginPromise = $phoneCodeLogin(vdata.formData.loginPhone, vdata.formData.smsCode);
} }
if (loginPromise == null) { if (loginPromise == null) {
return false; return false;
} }
// //
loginPromise.then(res => { loginPromise
.then((res) => {
// //
loginFinishFunc(res.data) loginFinishFunc(res.data);
// //
uni.setStorageSync('MerchantId', { uni.setStorageSync('MerchantId', {
merchantName: vdata.formData.merchantName, merchantName: vdata.formData.merchantName,
username: vdata.formData.username, username: vdata.formData.username
});
}) })
}).catch(e => { .catch((e) => {
getCode() getCode();
}) });
}) });
} }
const toPrivacy = () => { const toPrivacy = () => {
// #ifdef APP-PLUS // #ifdef APP-PLUS
go.to('PAGES_STATIC_POLICY') go.to('PAGES_STATIC_POLICY');
// #endif // #endif
// //
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
@ -354,27 +328,30 @@
uni.showToast({ uni.showToast({
title: '打开失败请稍后重试', // title: '打开失败请稍后重试', //
icon: 'none' icon: 'none'
}) });
}, }
}) });
// #endif // #endif
} };
watch(() => accountType.sel, (newval) => { watch(
() => accountType.sel,
(newval) => {
if (newval == 1) { if (newval == 1) {
vdata.formData.merchantName = uni.getStorageSync('merchantName') || '' vdata.formData.merchantName = uni.getStorageSync('merchantName') || '';
} else { } else {
vdata.formData.username = '' vdata.formData.username = '';
} }
}) }
);
// //
async function loginFinishFunc(loginBizData) { async function loginFinishFunc(loginBizData) {
// token // token
uni.setStorageSync('shopInfo',loginBizData.shopInfo) uni.setStorageSync('shopInfo', loginBizData.shopInfo);
uni.setStorageSync('tokenInfo',loginBizData.tokenInfo) uni.setStorageSync('tokenInfo', loginBizData.tokenInfo);
uni.setStorageSync('shopId',loginBizData.shopInfo.id) uni.setStorageSync('shopId', loginBizData.shopInfo.id);
uni.setStorageSync('loginType',loginBizData.loginType) uni.setStorageSync('loginType', loginBizData.loginType);
// //
go.to("PAGES_CREATE_ORDER") go.to('PAGES_CREATE_ORDER');
// uni.navigateTo({ // uni.navigateTo({
// url:'pagesCreateOrder/index/index' // url:'pagesCreateOrder/index/index'
// }) // })
@ -389,41 +366,39 @@
// //
if (!formUtil.regexp.mobile.test(vdata.formData.loginPhone)) { if (!formUtil.regexp.mobile.test(vdata.formData.loginPhone)) {
return infoBox.showToast("请输入正确的手机号") return infoBox.showToast('请输入正确的手机号');
} }
if (!vdata.formData.vercode) { if (!vdata.formData.vercode) {
return infoBox.showToast("请输入图像验证码"); return infoBox.showToast('请输入图像验证码');
} }
vdata.allowSendMsgFlag = false; // vdata.allowSendMsgFlag = false; //
let data = { let data = {
phone: vdata.formData.loginPhone, phone: vdata.formData.loginPhone,
vercode: vdata.formData.vercode, vercode: vdata.formData.vercode,
vercodeToken: vdata.formData.vercodeToken, vercodeToken: vdata.formData.vercodeToken
} };
// //
$sendSms(data, 'auth').then(({ $sendSms(data, 'auth')
bizData .then(({ bizData }) => {
}) => { infoBox.showSuccessToast('验证码发送成功');
infoBox.showSuccessToast('验证码发送成功')
timer.startTimeoutTask(1, 60, (subTime) => { timer.startTimeoutTask(1, 60, (subTime) => {
if (subTime <= 0) {
if (subTime <= 0) { // //
vdata.sendMsgText = '发送验证码' vdata.sendMsgText = '发送验证码';
vdata.allowSendMsgFlag = true; vdata.allowSendMsgFlag = true;
return false; return false;
} }
vdata.sendMsgText = `${subTime}s后可重新发送` vdata.sendMsgText = `${subTime}s后可重新发送`;
});
}) })
}).catch(() => { .catch(() => {
vdata.allowSendMsgFlag = true; vdata.allowSendMsgFlag = true;
}) });
} }
</script> </script>
@ -439,7 +414,7 @@
height: 376rpx; height: 376rpx;
padding: 176rpx 70rpx 0; padding: 176rpx 70rpx 0;
box-sizing: border-box; box-sizing: border-box;
background: url("/static/indexImg/user-bg.svg") center center no-repeat; background: url('/static/indexImg/user-bg.svg') center center no-repeat;
background-size: cover; background-size: cover;
text:first-child { text:first-child {
@ -452,7 +427,7 @@
text:last-child { text:last-child {
font-size: 50rpx; font-size: 50rpx;
font-weight: 600; font-weight: 600;
color: #48C0FF; color: #48c0ff;
} }
} }
@ -477,7 +452,7 @@
margin-top: 10rpx; margin-top: 10rpx;
margin-bottom: 50rpx; margin-bottom: 50rpx;
font-size: 26rpx; font-size: 26rpx;
color: #8C8C8C; color: #8c8c8c;
.select-box { .select-box {
display: flex; display: flex;
@ -491,7 +466,7 @@
.agreement, .agreement,
.policy { .policy {
color: #1D79FD; color: #1d79fd;
} }
} }
@ -505,12 +480,12 @@
.register { .register {
text:last-child { text:last-child {
color: #1D79FD; color: #1d79fd;
} }
} }
.forget { .forget {
color: #1D79FD; color: #1d79fd;
} }
} }

View File

@ -27,7 +27,7 @@
<view class="u-flex"> <view class="u-flex">
<view>{{item.nickName}}</view> <view>{{item.nickName}}</view>
</view> </view>
<view class="u-m-t-12 ">手机号:{{item.telephone}}</view> <view class="u-m-t-12 ">手机号:{{item.phone}}</view>
<view class=" u-font-24 u-m-t-12 u-flex"> <view class=" u-font-24 u-m-t-12 u-flex">
<text class="color-999" v-if="!item.isVip">非会员</text> <text class="color-999" v-if="!item.isVip">非会员</text>
<text class="color-main" v-else>会员</text> <text class="color-main" v-else>会员</text>
@ -86,6 +86,7 @@
}) })
function chooseUser(index, item) { function chooseUser(index, item) {
console.log(index, item)
if (index === undefined || item === undefined) { if (index === undefined || item === undefined) {
nouser.value = true nouser.value = true
return emitChooser({ return emitChooser({
@ -106,24 +107,25 @@
name: '', name: '',
totalElements: 0, totalElements: 0,
size: 10, size: 10,
isVip: 1
}) })
const list = reactive([]) const list = reactive([])
let hasAjax = ref(false) let hasAjax = ref(false)
async function getUser() { async function getUser() {
const res = await Api.queryAllShopUser(query)
console.log(res)
const { const {
content, records,
totalElements totalRow
} = await Api.queryAllShopUser(query) }=res.data
hasAjax.value = true hasAjax.value = true
list.length = content.length list.length = records.length
for (let i in content) { for (let i in records) {
list[i] = { list[i] = {
...content[i], ...records[i],
checked: false checked: false
} }
} }
query.totalElements = totalElements query.totalElements = totalRow
console.log(list); console.log(list);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,47 +1,70 @@
<template> <template>
<view class="mask" @tap="hideGoods" v-if="switchGoods"> <view>
<view class="mask" @tap="hideGoods" v-if="switchGoods"> </view>
</view> <view
<view class="fixed goods-box u-flex u-flex-col" :class="{active:switchGoods}" @tap.stop="nullFun"> class="fixed goods-box u-flex u-flex-col"
:class="{ active: switchGoods }"
@tap.stop="nullFun"
>
<view class="u-row-between top u-flex"> <view class="u-row-between top u-flex">
<view class="u-flex"> <view class="u-flex">
<view> <view>
<up-icon name="shopping-cart-fill" size="20" color="rgb(102,102,102)"></up-icon> <up-icon
name="shopping-cart-fill"
size="20"
color="rgb(102,102,102)"
></up-icon>
</view> </view>
<view class="u-m-l-10"> <view class="u-m-l-10"> 已选菜品({{ goodsNumber }}) </view>
已选菜品({{goodsNumber}})
</view> </view>
</view> <view
<view class="u-flex" @click="setModalShow('clear',true,'','是否清空点餐?')"> class="u-flex"
@click="setModalShow('clear', true, '', '是否清空点餐?')"
>
<view> <view>
<up-icon name="trash-fill" size="20" color="rgb(102,102,102)"></up-icon> <up-icon
</view> name="trash-fill"
<view class="u-m-l-10"> size="20"
清空点餐 color="rgb(102,102,102)"
></up-icon>
</view> </view>
<view class="u-m-l-10"> 清空点餐 </view>
</view> </view>
<view class="u-flex"> <view class="u-flex">
<view>合计:</view> <view>合计:</view>
<view class="u-m-l-10 color-red font-bold allPrice">{{allPrice}}</view> <view class="u-m-l-10 color-red font-bold allPrice">{{
allPrice
}}</view>
<view class=""></view> <view class=""></view>
</view> </view>
</view> </view>
<scroll-view scroll-y="true" style="height: 300px;background-color: #fff;"> <scroll-view
scroll-y="true"
style="height: 300px; background-color: #fff"
>
<!-- <scroll-view scroll-y="true" class=" u-flex-1 " > --> <!-- <scroll-view scroll-y="true" class=" u-flex-1 " > -->
<view class=" "> <view class=" ">
<view <view
class="color-333 item border-bottom u-p-l-20 u-p-r-20 u-p-b-10 u-p-t-20 u-flex u-row-center u-row-between" class="color-333 item border-bottom u-p-l-20 u-p-r-20 u-p-b-10 u-p-t-20 u-flex u-row-center u-row-between"
v-for="(item,index) in data" :key="item.id"> v-for="(item, index) in data"
:key="item.id"
>
<view class="u-flex u-col-top"> <view class="u-flex u-col-top">
<view class="u-p-r-20"> <view class="u-p-r-20">
{{ index + 1 }} {{ index + 1 }}
</view> </view>
<view class=""> <view class="">
<view>{{ item.name }}</view> <view>{{ item.name }}</view>
<view class="u-m-t-10 u-font-24 color-666">{{item.specInfo||''}}</view> <view class="u-m-t-10 u-font-24 color-666">{{
item.specInfo || ""
}}</view>
<view class="u-flex u-m-t-14"> <view class="u-flex u-m-t-14">
<up-icon name="edit-pen" @click="showModel('remark',index)" color="#333" <up-icon
size="16"></up-icon> name="edit-pen"
@click="showModel('remark', index)"
color="#333"
size="16"
></up-icon>
<view class="color-666 u-font-24"> <view class="color-666 u-font-24">
{{ item.note }} {{ item.note }}
</view> </view>
@ -50,10 +73,24 @@
</view> </view>
<view class="u-flex"> <view class="u-flex">
<view class="font-bold red u-m-r-32">{{formatPrice(item.lowPrice*item.number) }} <view v-if="item.is_time_discount" class="u-flex">
<view class="font-bold red"
>{{ returnLimitTotalPrice(item) }}
</view>
<view class="font-bold u-m-r-32 old-price">
{{ formatPrice(item.lowPrice * item.number) }}
</view>
</view>
<view class="font-bold red u-m-r-32" v-else
>{{ formatPrice(item.lowPrice * item.number) }}
</view> </view>
<view class="u-flex" @tap="updateNumber(false, index, item)"> <view class="u-flex" @tap="updateNumber(false, index, item)">
<image src="/pagesCreateOrder/static/images/icon-reduce-black.svg" class="icon" mode=""> <image
src="/pagesCreateOrder/static/images/icon-reduce-black.svg"
class="icon"
mode=""
>
</image> </image>
</view> </view>
<view class="u-p-l-30 u-p-r-30 color-333" style=""> <view class="u-p-l-30 u-p-r-30 color-333" style="">
@ -61,13 +98,22 @@
</view> </view>
<template v-if="item.type != 'package'"> <template v-if="item.type != 'package'">
<view class="u-flex" @tap="updateNumber(true, index, item)"> <view class="u-flex" @tap="updateNumber(true, index, item)">
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" class="icon" mode=""> <image
src="/pagesCreateOrder/static/images/icon-add-black.svg"
class="icon"
mode=""
>
</image> </image>
</view> </view>
</template> </template>
<template v-else> <template v-else>
<view class="u-flex"> <view class="u-flex">
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" style=" filter: opacity(30%);" class="icon" mode=""> <image
src="/pagesCreateOrder/static/images/icon-add-black.svg"
style="filter: opacity(30%)"
class="icon"
mode=""
>
</image> </image>
</view> </view>
</template> </template>
@ -76,287 +122,373 @@
<my-empty v-if="!data.length" text="暂未有添加商品"></my-empty> <my-empty v-if="!data.length" text="暂未有添加商品"></my-empty>
</view> </view>
<!-- 历史订单 --> <!-- 历史订单 -->
<view v-if="historyOrder.length > 0" <view
class="u-p-t-32 u-p-b-32 u-p-r-28 u-p-l-28 u-m-t-40 bg-fff u-flex u-row-between"> v-if="historyOrder.length > 0"
<view class="color-333" style="font-weight: bold;">历史订单</view> class="u-p-t-32 u-p-b-32 u-p-r-28 u-p-l-28 u-m-t-40 bg-fff u-flex u-row-between"
>
<view class="color-333" style="font-weight: bold">历史订单</view>
<view class="color-666"> <view class="color-666">
<uni-icons color="#666" type="trash"></uni-icons> <uni-icons color="#666" type="trash"></uni-icons>
<text class="u-m-l-10" @tap="setModalShow('clear',true,'allHistoryOrder','清空历史订单')">清空历史订单</text> <text
class="u-m-l-10"
@tap="
setModalShow('clear', true, 'allHistoryOrder', '清空历史订单')
"
>清空历史订单</text
>
</view> </view>
</view> </view>
<view v-for="(item,index) in historyOrder" :key="index" style="margin-top: 20rpx;"> <view
<view v-if="historyOrder.length > 0" v-for="(item, index) in historyOrder"
class="u-p-t-32 border-top bg-fff u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between"> :key="index"
<view class="color-333" style="font-size: 30rpx;">{{item.placeNum}}次下单</view> style="margin-top: 20rpx"
>
<view
v-if="historyOrder.length > 0"
class="u-p-t-32 border-top bg-fff u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between"
>
<view class="color-333" style="font-size: 30rpx"
>{{ item.placeNum }}次下单</view
>
<view class="color-666"> <view class="color-666">
<!-- <uni-icons color="#666" type="trash"></uni-icons> <!-- <uni-icons color="#666" type="trash"></uni-icons>
<text class="u-m-l-10" <text class="u-m-l-10"
@tap="setModalShow('clear',true,item.placeNum,'清空第'+item.placeNum+'次下单历史订单')">清空</text> --> @tap="setModalShow('clear',true,item.placeNum,'清空第'+item.placeNum+'次下单历史订单')">清空</text> -->
</view> </view>
</view> </view>
<view class="color-333 item border-top u-flex u-row-center u-row-between" style="margin-left: 60rpx;" <view
v-for="(v,i) in item.info" :key="i"> class="color-333 item border-top u-flex u-row-center u-row-between"
<view style="display: flex;align-items: center;"> style="margin-left: 60rpx"
<view class="up-line-1" style="margin-right: 10rpx;">{{v.productName}}</view> v-for="(v, i) in item.info"
<uni-tag v-if="v.returnNum>0" :text="'退菜X'+v.returnNum" :key="i"
custom-style="background-color: #EB4F4F; border-color: #EB4F4F; color: #fff;"> >
<view style="display: flex; align-items: center">
<view class="up-line-1" style="margin-right: 10rpx">{{
v.productName
}}</view>
<uni-tag
v-if="v.returnNum > 0"
:text="'退菜X' + v.returnNum"
custom-style="background-color: #EB4F4F; border-color: #EB4F4F; color: #fff;"
>
</uni-tag> </uni-tag>
</view> </view>
<view class="u-flex" style="flex-shrink: 0;margin-top: 20rpx;"> <view
<view class="font-bold red u-m-r-32">{{formatPrice(v.price*(v.num - v.returnNum)) }}</view> class="u-flex"
<view class="u-m-l-30 u-m-r-30 color-333"> X{{v.num.toFixed(2)}} </view> style="flex-shrink: 0; margin-top: 20rpx"
v-if="v.is_time_discount || v.isTimeDiscount"
>
<view class="font-bold red u-m-r-32"
>{{ formatPrice(v.price * (v.num - v.returnNum)) }}</view
>
<view class="u-m-l-30 u-m-r-30 color-333">
X{{ v.num.toFixed(2) }}
</view>
</view>
<view
class="u-flex"
style="flex-shrink: 0; margin-top: 20rpx"
v-else
>
<view class="font-bold red u-m-r-32"
>{{ formatPrice(v.price * (v.num - v.returnNum)) }}</view
>
<view class="u-m-l-30 u-m-r-30 color-333">
X{{ v.num.toFixed(2) }}
</view>
</view> </view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<view class="u-row-between bottom u-flex" style="position: absolute;left: 0;bottom: 0;background-color: #fff;"> <view
class="u-row-between bottom u-flex"
style="position: absolute; left: 0; bottom: 0; background-color: #fff"
>
<view class="u-flex" @click="hideGoods"> <view class="u-flex" @click="hideGoods">
<view> <view>
<up-icon name="arrow-left" size="14" color="#333"></up-icon> <up-icon name="arrow-left" size="14" color="#333"></up-icon>
</view> </view>
<view class="u-m-l-10"> <view class="u-m-l-10"> 返回 </view>
返回
</view>
</view> </view>
<view class="u-flex luodan" @click="toConfimOrder"> <view class="u-flex luodan" @click="toConfimOrder">
<view>落单</view> <view>落单</view>
</view> </view>
</view> </view>
</view> </view>
<view class="car u-flex u-row-between u-col-bottom u-relative" @touchmove.stop.prevent="moveHandle" <view
:style="{transform: 'translateY(' + offset.y + 'px)'}" @touchstart="touchstart" @touchmove="touchmove" class="car u-flex u-row-between u-col-bottom u-relative"
@touchend="touchend"> @touchmove.stop.prevent="moveHandle"
:style="{ transform: 'translateY(' + offset.y + 'px)' }"
@touchstart="touchstart"
@touchmove="touchmove"
@touchend="touchend"
>
<view class="u-absolute goods bg-fff"> <view class="u-absolute goods bg-fff">
<view <view
class="u-p-t-32 color-666 border-bottom bg-fff u-absolute total u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between"> class="u-p-t-32 color-666 border-bottom bg-fff u-absolute total u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between"
>
<view>已添加{{ goodsNumber }}件商品</view> <view>已添加{{ goodsNumber }}件商品</view>
<view class="color-666" @tap="setModalShow('clear', true)"> <view class="color-666" @tap="setModalShow('clear', true)">
<uni-icons color="#666" type="trash"></uni-icons> <uni-icons color="#666" type="trash"></uni-icons>
<text class="u-m-l-10">清空</text> <text class="u-m-l-10">清空</text>
</view> </view>
</view> </view>
</view> </view>
<view class="icon-car-box" @tap="toggleGoods"> <view class="icon-car-box" @tap="toggleGoods">
<image src="/pagesCreateOrder/static/images/icon-car.svg" class="icon-car" /> <image
src="/pagesCreateOrder/static/images/icon-car.svg"
class="icon-car"
/>
<view class="dot">{{ goodsNumber }}</view> <view class="dot">{{ goodsNumber }}</view>
</view> </view>
</view> </view>
<up-modal title="提示" :content="modal.title" :show="modal.clear" showCancelButton closeOnClickOverlay <up-modal
@confirm="confirmModelConfirm" @cancel="setModalShow('clear',false)" @close="setModalShow('clear',false)" title="提示"
width="300px"></up-modal> :content="modal.title"
<one-remark width="400px" @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark> :show="modal.clear"
showCancelButton
closeOnClickOverlay
@confirm="confirmModelConfirm"
@cancel="setModalShow('clear', false)"
@close="setModalShow('clear', false)"
width="300px"
></up-modal>
<one-remark
width="400px"
@confirm="goodsOneRemarkConfirm"
title="单品备注"
:ref="setModel"
name="remark"
></one-remark>
</view>
</template> </template>
<script setup> <script setup>
import go from '@/commons/utils/go.js'; import go from "@/commons/utils/go.js";
import infoBox from '@/commons/utils/infoBox.js'; import infoBox from "@/commons/utils/infoBox.js";
import oneRemark from '/pagesCreateOrder/confirm-order/components/remark' import oneRemark from "/pagesCreateOrder/confirm-order/components/remark";
import { import { formatPrice } from "@/commons/utils/format.js";
formatPrice import { $tbProduct, adminProduct } from "@/http/yskApi/goods.js";
} from '@/commons/utils/format.js';
import {
$tbProduct,
adminProduct
} from '@/http/yskApi/goods.js'
// import { // import {
// addWXCart // addWXCart
// } from "@/http/yskApi/Instead.js" // } from "@/http/yskApi/Instead.js"
import { import { getElRect } from "@/commons/utils/safe-bottom.js";
getElRect import * as Api from "@/http/yskApi/Instead.js";
} from '@/commons/utils/safe-bottom.js' import { computed, ref, onMounted, reactive, watch, inject } from "vue";
import * as Api from '@/http/yskApi/Instead.js' import BigNumber from "bignumber.js";
import {
computed, const yskUtils = inject("yskUtils");
ref, const shopInfo = uni.getStorageSync("shopInfo");
onMounted,
reactive, let shopList = ref();
watch
} from 'vue';
let shopList = ref()
const props = defineProps({ const props = defineProps({
limitTimeDiscount: {
type: Object,
default: () => {
return {};
},
},
sysInfo: { sysInfo: {
type: Object, type: Object,
default: () => { default: () => {
return { return {
windowWidth: 0, windowWidth: 0,
windowHeight: 0, windowHeight: 0,
statusBarHeight: 0 statusBarHeight: 0,
} };
} },
}, },
historyOrder: { historyOrder: {
type: Array, type: Array,
default: () => { default: () => {
return [] return [];
} },
}, },
instance: { instance: {
type: Object, type: Object,
default: { default: {},
}
}, },
data: { data: {
type: Array, type: Array,
default: () => { default: () => {
return [] return [];
} },
}, },
isCreateOrderToDetail: { isCreateOrderToDetail: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
user: { user: {
type: Object, type: Object,
default: () => { default: () => {
return { return {
id: "" id: "",
} };
} },
}, },
table: { table: {
type: Object, type: Object,
default: () => { default: () => {
return { return {};
},
}
}
}, },
masterId: { masterId: {
type: [String, Number], type: [String, Number],
default: '' default: "",
},
});
function returnLimitPrice(data) {
const price = yskUtils.limitUtils.returnPrice({
goods: data,
shopInfo: shopInfo,
limitTimeDiscountRes: props.limitTimeDiscount,
shopUserInfo: null,
idKey: "id",
});
return price
} }
})
const edmits = defineEmits(['clear', 'updateNumber', 'updateSafeBottom', 'updateCart']) function returnLimitTotalPrice(data) {
const price = yskUtils.limitUtils.returnPrice({
goods: data,
shopInfo: shopInfo,
limitTimeDiscountRes: props.limitTimeDiscount,
shopUserInfo: null,
idKey: "id",
});
return BigNumber(price).times(data.number).toNumber();
}
const edmits = defineEmits([
"clear",
"updateNumber",
"updateSafeBottom",
"updateCart",
]);
const modal = reactive({ const modal = reactive({
key: '', key: "",
title: '', title: "",
type: '', type: "",
clear: false clear: false,
}) });
let allHistoryOrder = ref([]); let allHistoryOrder = ref([]);
const allPrice = computed(() => { const allPrice = computed(() => {
let cartPrice = props.data.reduce((prve, cur) => { let cartPrice = props.data.reduce((prve, cur) => {
let price = Math.floor((cur.lowPrice * cur.number) * 100) / 100 let price = (cur.is_time_discount? returnLimitPrice(cur) : cur.lowPrice) * cur.number
return prve + price return BigNumber(prve).plus(price);
}, 0) }, 0);
console.log('cartPrice',cartPrice)
let historyOrderPrice = allHistoryOrder.value.reduce((prve, cur) => { let historyOrderPrice = allHistoryOrder.value.reduce((prve, cur) => {
let price = Math.floor((cur.price * (cur.num - cur.returnNum)) * 100) / 100 const isTimeDiscount=cur.is_time_discount||cur.isTimeDiscount
return prve + price let price = (isTimeDiscount? returnLimitPrice(cur) : cur.price)* (cur.num - cur.returnNum)
}, 0) console.log('price',price)
return BigNumber(prve).plus(price);
}, 0);
console.log('historyOrderPrice',historyOrderPrice)
return (cartPrice + historyOrderPrice).toFixed(2) return BigNumber(cartPrice).plus(historyOrderPrice);
}) });
const models = new Map(); const models = new Map();
const modelData = reactive({ const modelData = reactive({
data: {}, data: {},
selIndex: -1 selIndex: -1,
}) });
// //
let note = ref('') let note = ref("");
watch(() => props.historyOrder, (newval) => { watch(
() => props.historyOrder,
(newval) => {
allHistoryOrder.value = []; allHistoryOrder.value = [];
newval.forEach(item => { newval.forEach((item) => {
allHistoryOrder.value = [...allHistoryOrder.value, ...item.info] allHistoryOrder.value = [...allHistoryOrder.value, ...item.info];
}) });
}) }
);
function setModel(el) { function setModel(el) {
if (el && el.$attrs['name']) { if (el && el.$attrs["name"]) {
models.set(el.$attrs['name'], el); models.set(el.$attrs["name"], el);
} }
} }
function showModel(key, index) { function showModel(key, index) {
modelData.data = props.data[index] modelData.data = props.data[index];
modelData.selIndex = index modelData.selIndex = index;
const model = models.get(key) const model = models.get(key);
model && model.open({ model &&
remark: modelData.data.note || '' model.open({
}) remark: modelData.data.note || "",
});
} }
function confirmModelConfirm() { function confirmModelConfirm() {
if (modal.key == 'clear') { if (modal.key == "clear") {
clear() clear();
} }
} }
// //
async function goodsOneRemarkConfirm(e) { async function goodsOneRemarkConfirm(e) {
const cart = props.data[modelData.selIndex] const cart = props.data[modelData.selIndex];
await Api.$updateCart({ await Api.$updateCart({
cartId: cart.id, cartId: cart.id,
productId: cart.productId, productId: cart.productId,
skuId: cart.skuId, skuId: cart.skuId,
tableId: props.table.tableId, tableId: props.table.tableId,
note: e.remark, note: e.remark,
num: cart.number // 0 num: cart.number, // 0
}) });
edmits('updateCart') edmits("updateCart");
} }
// //
function setModalShow(key = 'show', show = true, type = '', title = '') { function setModalShow(key = "show", show = true, type = "", title = "") {
if (title) { if (title) {
modal.title = title modal.title = title;
} }
if (type) { if (type) {
modal.type = type modal.type = type;
} }
modal.key = key modal.key = key;
modal[key] = show modal[key] = show;
console.log(modal, 123); console.log(modal, 123);
} }
function nullFun() {}
function nullFun() {
}
// mask // mask
let switchGoods = ref(false) let switchGoods = ref(false);
function hideGoods() { function hideGoods() {
switchGoods.value = false switchGoods.value = false;
} }
function showGoods() { function showGoods() {
switchGoods.value = true switchGoods.value = true;
} }
function toggleGoods() { function toggleGoods() {
switchGoods.value = !switchGoods.value switchGoods.value = !switchGoods.value;
// //
// getshopsInfo() // getshopsInfo()
} }
function getshopsInfo() { function getshopsInfo() {
let arr = uni.getStorageSync('wxList') let arr = uni.getStorageSync("wxList");
let att = [] let att = [];
arr.forEach(async ele => { arr.forEach(async (ele) => {
let res = await adminProduct(ele.product_id) let res = await adminProduct(ele.product_id);
console.log(res); console.log(res);
att.push({ att.push({
...res.data, ...res.data,
...ele, ...ele,
ele ele,
}) });
}) });
setTimeout(() => { setTimeout(() => {
// uni.setStorageSync('shopsList', att) // uni.setStorageSync('shopsList', att)
shopList.value = att shopList.value = att;
console.log(att, '初始化') console.log(att, "初始化");
}, 200) }, 200);
// product_id() // product_id()
// const findCategory = layoutData.category.list.find(v => v.shopId == goods.shop_id) // const findCategory = layoutData.category.list.find(v => v.shopId == goods.shop_id)
@ -364,18 +496,12 @@
function toConfimOrder() { function toConfimOrder() {
if (props.data.length <= 0) { if (props.data.length <= 0) {
return infoBox.showToast('还没有选择商品') return infoBox.showToast("还没有选择商品");
} }
if (props.table.id) { if (props.table.id) {
const { const { id, name, maxCapacity, status, type } = props.table;
id, go.to("PAGES_CONFIRM_ORDER", {
name,
maxCapacity,
status,
type
} = props.table
go.to('PAGES_CONFIRM_ORDER', {
masterId: props.masterId, masterId: props.masterId,
type, type,
tableId: id, tableId: id,
@ -384,58 +510,58 @@
status, status,
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0, isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0,
tableCode: props.table.tableCode, tableCode: props.table.tableCode,
}) });
} else { } else {
go.to('PAGES_CONFIRM_ORDER', { go.to("PAGES_CONFIRM_ORDER", {
masterId: props.masterId, masterId: props.masterId,
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0, isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0,
tableCode: props.table.tableCode, tableCode: props.table.tableCode,
}) });
} }
hideGoods() hideGoods();
} }
const goodsNumber = computed(() => { const goodsNumber = computed(() => {
let result = 0 let result = 0;
let cart = props.data.reduce((prve, cur) => { let cart = props.data.reduce((prve, cur) => {
return prve + cur.number return prve + cur.number;
}, 0) }, 0);
let historyOrderNum = allHistoryOrder.value.reduce((prve, cur) => { let historyOrderNum = allHistoryOrder.value.reduce((prve, cur) => {
return prve + cur.num return prve + cur.num;
}, 0) }, 0);
result = cart + historyOrderNum result = cart + historyOrderNum;
result = result > 0 ? result.toFixed(2) : 0 result = result > 0 ? result.toFixed(2) : 0;
return result >= 99 ? 99 : parseFloat(result) return result >= 99 ? 99 : parseFloat(result);
}) });
function updateNumber(isAdd, index, goods) { function updateNumber(isAdd, index, goods) {
const step = isAdd ? 1 : -1 const step = isAdd ? 1 : -1;
const newval = (goods.number) + step const newval = goods.number + step;
const par = { const par = {
num: newval, num: newval,
index: index, index: index,
goods: goods goods: goods,
};
edmits("updateNumber", par);
} }
edmits('updateNumber', par)
}
const offset = ref({ const offset = ref({
x: 0, x: 0,
y: (props.sysInfo.windowHeight - 70 - 40) / 2 y: (props.sysInfo.windowHeight - 70 - 40) / 2,
}) });
const startPoint = ref({ const startPoint = ref({
x: 0, x: 0,
y: 0 y: 0,
}) });
watch(() => props.sysInfo.windowHeight, (newval) => { watch(
console.log('---------'); () => props.sysInfo.windowHeight,
(newval) => {
console.log("---------");
console.log(newval); console.log(newval);
offset.value.y = (newval - 70 - 40) / 2 offset.value.y = (newval - 70 - 40) / 2;
}) }
);
// watch(() => props.data, (n) => { // watch(() => props.data, (n) => {
// shopList.value = uni.getStorageSync('wxList') // shopList.value = uni.getStorageSync('wxList')
// getshopsInfo() // getshopsInfo()
@ -444,37 +570,37 @@
function touchstart(event) { function touchstart(event) {
startPoint.value = { startPoint.value = {
x: event.touches[0].clientX, x: event.touches[0].clientX,
y: event.touches[0].clientY y: event.touches[0].clientY,
}; };
} }
function touchmove(event) { function touchmove(event) {
const currentPoint = { const currentPoint = {
x: event.touches[0].clientX, x: event.touches[0].clientX,
y: event.touches[0].clientY y: event.touches[0].clientY,
}; };
const delta = { const delta = {
x: currentPoint.x - startPoint.value.x, x: currentPoint.x - startPoint.value.x,
y: currentPoint.y - startPoint.value.y y: currentPoint.y - startPoint.value.y,
}; };
const minY = props.sysInfo.statusBarHeight || 0, const minY = props.sysInfo.statusBarHeight || 0,
maxY = props.sysInfo.windowHeight - 70 - 40; maxY = props.sysInfo.windowHeight - 70 - 40;
let newY = offset.value.y + delta.y let newY = offset.value.y + delta.y;
if (newY > maxY) { if (newY > maxY) {
newY = maxY newY = maxY;
} }
if (newY < minY) { if (newY < minY) {
newY = minY newY = minY;
} }
offset.value = { offset.value = {
// x: offset.value.x + delta.x, // x: offset.value.x + delta.x,
y: newY y: newY,
}; };
startPoint.value = currentPoint; startPoint.value = currentPoint;
} }
function moveHandle() { function moveHandle() {
return false return false;
} }
function touchend(e) { function touchend(e) {
@ -482,25 +608,26 @@
} }
function clear() { function clear() {
if (modal.type == 'cart') { if (modal.type == "cart") {
hideGoods() hideGoods();
} }
setModalShow('clear', false) setModalShow("clear", false);
edmits('clear', modal.type) edmits("clear", modal.type);
// setModalShow('clear', false) // setModalShow('clear', false)
// edmits('clear') // edmits('clear')
// hideGoods() // hideGoods()
} }
onMounted(async () => { onMounted(async () => {
getElRect('car', props.instance).then(res => { getElRect("car", props.instance)
edmits('updateSafeBottom', res) .then((res) => {
}).catch(err => { edmits("updateSafeBottom", res);
})
.catch((err) => {
console.log(err); console.log(err);
}) });
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -530,7 +657,7 @@
background-color: #fff; background-color: #fff;
border-radius: 12px 0 0 12px; border-radius: 12px 0 0 12px;
overflow: hidden; overflow: hidden;
transition: all .2s ease-in-out; transition: all 0.2s ease-in-out;
transform: translateX(100%); transform: translateX(100%);
z-index: 10; z-index: 10;
@ -571,7 +698,7 @@
.icon { .icon {
width: 40rpx; width: 40rpx;
height: 40rpx height: 40rpx;
} }
.mask { .mask {
@ -579,14 +706,12 @@
background: rgba(51, 51, 51, 0.5); background: rgba(51, 51, 51, 0.5);
} }
.goods { .goods {
position: fixed; position: fixed;
width: 50vh; width: 50vh;
bottom: 0; bottom: 0;
right: 0; right: 0;
transition: all .2s ease-in-out; transition: all 0.2s ease-in-out;
overflow: hidden; overflow: hidden;
z-index: 3; z-index: 3;
@ -604,7 +729,7 @@
} }
.red { .red {
color: #EB4F4F; color: #eb4f4f;
} }
.car { .car {
@ -629,19 +754,19 @@
top: 0; top: 0;
width: 28rpx; width: 28rpx;
height: 28rpx; height: 28rpx;
background: #EB4F4F; background: #eb4f4f;
border-radius: 50%; border-radius: 50%;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-size: 20rpx; font-size: 20rpx;
font-weight: bold; font-weight: bold;
color: #FFFFFF; color: #ffffff;
} }
} }
.price { .price {
color: #EB4F4F; color: #eb4f4f;
margin-left: calc(38rpx + $car-size); margin-left: calc(38rpx + $car-size);
transform: translateY(calc($car-top / 2)); transform: translateY(calc($car-top / 2));
} }
@ -651,4 +776,8 @@
height: $car-size; height: $car-size;
} }
} }
.old-price {
color: #999;
text-decoration: line-through;
}
</style> </style>

View File

@ -1,49 +1,137 @@
<template> <template>
<view class="u-relative u-flex item box-shadow " @tap="emitEvent('showDetail')"> <view
class="u-relative u-flex item box-shadow"
@tap="emitEvent('showDetail')"
>
<view class="limit-discount" v-if="data.is_time_discount">限时折扣</view>
<!-- 已下架 --> <!-- 已下架 -->
<view v-if="!data.isSale" <view
style="display: flex;align-items: center;justify-content: center;width: 100%;height: 100%;z-index: 9999;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);background-color: rgba(0, 0, 0, .6);"> v-if="!data.isSale"
<image style="width: 220px;height: 220px;" src="@/static/iconImg/icon_goods_yxj.svg" /> style="
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 9999;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.6);
"
>
<image
style="width: 220px; height: 220px"
src="@/static/iconImg/icon_goods_yxj.svg"
/>
</view> </view>
<!-- 未开售 --> <!-- 未开售 -->
<view v-else-if="!isProductAvailable(data.days,data.startTime.substring(11),data.endTime.substring(11))" <view
style="display: flex;align-items: center;justify-content: center;width: 100%;height: 100%;z-index: 9999;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);background-color: rgba(0, 0, 0, .6);"> v-else-if="
<image style="width: 220px;height: 220px;" src="@/static/iconImg/icon_goods_wks.svg" /> !isProductAvailable(
data.days,
data.startTime.substring(11),
data.endTime.substring(11)
)
"
style="
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 9999;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.6);
"
>
<image
style="width: 220px; height: 220px"
src="@/static/iconImg/icon_goods_wks.svg"
/>
</view> </view>
<!-- 已售罄 --> <!-- 已售罄 -->
<view v-else-if="(data.isStock && data.stockNumber<=0) " <view
style="display: flex;align-items: center;justify-content: center;width: 100%;height: 100%;z-index: 9999;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);background-color: rgba(0, 0, 0, .6);"> v-else-if="data.isStock && data.stockNumber <= 0"
<image style="width: 220px;height: 220px;" src="@/static/iconImg/icon_goods_sq.svg" /> style="
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 9999;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.6);
"
>
<image
style="width: 220px; height: 220px"
src="@/static/iconImg/icon_goods_sq.svg"
/>
</view> </view>
<!-- 库存不足 --> <!-- 库存不足 -->
<view v-else-if="data.isSoldStock" <view
style="display: flex;align-items: center;justify-content: center;width: 100%;height: 100%;z-index: 9999;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);background-color: rgba(0, 0, 0, .6);"> v-else-if="data.isSoldStock"
<image style="width: 220px;height: 220px;" src="@/static/iconImg/Insufficient_inventory.svg" /> style="
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 9999;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.6);
"
>
<image
style="width: 220px; height: 220px"
src="@/static/iconImg/Insufficient_inventory.svg"
/>
</view> </view>
<view class="img"> <view class="img">
<image lazy-load :src="data.coverImg" mode="aspectFill"></image> <image lazy-load :src="data.coverImg" mode="aspectFill"></image>
</view> </view>
<!-- <image lazy-load class="img" :src="data.coverImg" mode="" ></image> --> <!-- <image lazy-load class="img" :src="data.coverImg" mode="" ></image> -->
<view class="info u-flex u-flex-col u-row-right"> <view class="info u-flex u-flex-col u-row-right">
<view class="u-flex w-full u-row-right u-p-r-20 u-p-b-16 u-flex-1 u-flex-col"> <view
class="u-flex w-full u-row-right u-p-r-20 u-p-b-16 u-flex-1 u-flex-col"
>
<template v-if="!isSellout"> <template v-if="!isSellout">
<template v-if="data.type == 'sku' || data.groupType == 1"> <template v-if="data.type == 'sku' || data.groupType == 1">
<view class="u-flex u-row-right w-full"> <view class="u-flex u-row-right w-full">
<view class="u-flex"> <view class="u-flex">
<button class="btn" hover-class="btn-hover-class" <button
@tap.stop="emitEvent('chooseGuige')">选规格</button> class="btn"
hover-class="btn-hover-class"
@tap.stop="emitEvent('chooseGuige')"
>
选规格
</button>
</view> </view>
</view> </view>
</template> </template>
<template v-else-if="data.type == 'weight'"> <template v-else-if="data.type == 'weight'">
<view class="u-flex u-row-right w-full"> <view class="u-flex u-row-right w-full">
<view class="u-flex"> <view class="u-flex">
<button class="btn" hover-class="btn-hover-class" <button
@tap.stop="emitEvent('tapweigh')">称重</button> class="btn"
hover-class="btn-hover-class"
@tap.stop="emitEvent('tapweigh')"
>
称重
</button>
</view> </view>
</view> </view>
</template> </template>
@ -52,78 +140,89 @@
<view class="u-flex icon-btn"> <view class="u-flex icon-btn">
<template v-if="data.chooseNumber"> <template v-if="data.chooseNumber">
<view class="u-flex" @tap.stop="emitEvent('reduce')"> <view class="u-flex" @tap.stop="emitEvent('reduce')">
<image src="/pagesCreateOrder/static/images/icon-reduce.svg" class="icon" <image
mode=""> src="/pagesCreateOrder/static/images/icon-reduce.svg"
class="icon"
mode=""
>
</image> </image>
</view> </view>
<view class="u-font-32"> <view class="u-font-32">
{{ data.chooseNumber }} {{ data.chooseNumber }}
</view> </view>
</template> </template>
<view class="u-flex" @tap.stop="emitEvent(data.type=='weight'?'tapweigh':'add')"> <view
<image src="/pagesCreateOrder/static/images/icon-add.svg" class="icon" mode=""> class="u-flex"
@tap.stop="
emitEvent(data.type == 'weight' ? 'tapweigh' : 'add')
"
>
<image
src="/pagesCreateOrder/static/images/icon-add.svg"
class="icon"
mode=""
>
</image> </image>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
</template> </template>
<template v-else> <template v-else>
<view class=" u-m-t-16 u-row-center u-col-center"> <view class="u-m-t-16 u-row-center u-col-center"> 已售罄 </view>
已售罄
</view>
</template> </template>
</view> </view>
<view class="bg-fff u-p-20 w-full"> <view class="bg-fff u-p-20 w-full">
<view class="u-flex u-row-between u-font-16"> <view class="u-flex u-row-between u-font-16">
<view>{{ data.name }}</view> <view>{{ data.name }}</view>
<view class="u-flex" v-if="data.is_time_discount">
<view class="font-bold u-m-t-16"> <view class="font-bold u-m-t-16">
{{data.lowPrice}} {{ data.timeLimitPrice }}
</view> </view>
<view class="u-m-t-16 old-price"> {{ data.lowPrice }} </view>
</view> </view>
<view class="font-bold u-m-t-16" v-else> {{ data.lowPrice }} </view>
</view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { import { computed, toRef, toRefs, inject, watch } from "vue";
computed,
toRef,
toRefs,
watch
} from 'vue';
import dayjs from "dayjs"; import dayjs from "dayjs";
import isBetween from "dayjs/plugin/isBetween"; import isBetween from "dayjs/plugin/isBetween";
dayjs.extend(isBetween) const yskUtils = inject("yskUtils");
import { dayjs.extend(isBetween);
onLoad import { onLoad } from "@dcloudio/uni-app";
} from '@dcloudio/uni-app'
const props = defineProps({ const props = defineProps({
limitTimeDiscount: {
type: Object,
default: () => {
return null;
},
},
img: { img: {
type: Object, type: Object,
default: { default: {
width: '250rpx', width: "250rpx",
height: '272rpx' height: "272rpx",
} },
}, },
windowWidth: { windowWidth: {
//px //px
type: Number, type: Number,
default: 0 default: 0,
}, },
windowHeight: { windowHeight: {
//px //px
type: Number, type: Number,
default: 0 default: 0,
}, },
layout: { layout: {
type: String, type: String,
default: 'default' default: "default",
}, },
index: { index: {
type: [Number, String], type: [Number, String],
@ -131,41 +230,43 @@
isSeatFee: { isSeatFee: {
// //
type: Boolean, type: Boolean,
default: false default: false,
}, },
data: { data: {
type: Object, type: Object,
default: () => { default: () => {
return { return {
chooseNumber: 0 chooseNumber: 0,
} };
} },
}, },
gap: { gap: {
//px //px
type: Number, type: Number,
default: 20 default: 20,
} },
}) });
watch(() => props.windowWidth, (newval) => { watch(
() => props.windowWidth,
(newval) => {
console.log(newval); console.log(newval);
}) }
);
const computedImgStyle = computed(() => { const computedImgStyle = computed(() => {
const stylobj = { const stylobj = {
width: props.img.width, width: props.img.width,
height: props.img.height height: props.img.height,
} };
if (props.layout == 'default') { if (props.layout == "default") {
stylobj.width = (props.windowWidth - props.gap * 3) / 2 + 'px' stylobj.width = (props.windowWidth - props.gap * 3) / 2 + "px";
stylobj.height = (props.windowHeight - props.gap * 2 - 40) / 2 + 'px' stylobj.height = (props.windowHeight - props.gap * 2 - 40) / 2 + "px";
console.log(stylobj); console.log(stylobj);
return stylobj return stylobj;
} }
return stylobj return stylobj;
}) });
// const asd = computed(()=>{ // const asd = computed(()=>{
@ -179,63 +280,65 @@
// //
function isGoods() { function isGoods() {
return props.data.hasOwnProperty('id') return props.data.hasOwnProperty("id");
} }
// //
const isSellout = computed(() => { const isSellout = computed(() => {
const item = props.data const item = props.data;
if (!isGoods()) { if (!isGoods()) {
return false return false;
} }
return ( return (
item.isPauseSale || item.isPauseSale ||
(item.typeEnum !== "sku" && item.isStock == 1 && item.stockNumber <= 0) (item.typeEnum !== "sku" && item.isStock == 1 && item.stockNumber <= 0)
); );
}) });
const emits = defineEmits([
const emits = defineEmits(['add', 'reduce', 'chooseGuige', 'showDetail', 'tapweigh']) "add",
"reduce",
"chooseGuige",
"showDetail",
"tapweigh",
]);
// //
// //
function isProductAvailable(sellDaysStr, startTimeStr, endTimeStr) { function isProductAvailable(sellDaysStr, startTimeStr, endTimeStr) {
    // //
    const sellDays = sellDaysStr.split(','); const sellDays = sellDaysStr.split(",");
    const now = dayjs(); const now = dayjs();
    const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; const days = [
    const currentDay = days[now.day()]; "Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];
const currentDay = days[now.day()]; // console.log(':', currentDay); // console.log(':', sellDays); //
    // console.log(':', currentDay); if (!sellDays.includes(currentDay)) {
    // console.log(':', sellDays); // console.log('');
return false;
}
    // const startTime = dayjs(`${now.format("YYYY-MM-DD")} ${startTimeStr}`);
    if (!sellDays.includes(currentDay)) { let endTime = dayjs(`${now.format("YYYY-MM-DD")} ${endTimeStr}`); //
        // console.log('');
        return false;
    }
    const startTime = dayjs(`${now.format('YYYY-MM-DD')} ${startTimeStr}`); if (endTime.isBefore(startTime)) {
    let endTime = dayjs(`${now.format('YYYY-MM-DD')} ${endTimeStr}`); endTime = endTime.add(1, "day");
} // console.log('当前时间:', now.format('YYYY-MM-DD HH:mm:ss')); // console.log('开始时间:', startTime.format('YYYY-MM-DD HH:mm:ss')); // console.log(':', endTime.format('YYYY-MM-DD HH:mm:ss'));
    // const isInRange = now.isBetween(startTime, endTime, null, "[)"); // console.log(':', isInRange);
    if (endTime.isBefore(startTime)) { return isInRange;
        endTime = endTime.add(1, 'day');
    }
    // console.log(':', now.format('YYYY-MM-DD HH:mm:ss'));
    // console.log(':', startTime.format('YYYY-MM-DD HH:mm:ss'));
    // console.log(':', endTime.format('YYYY-MM-DD HH:mm:ss'));
    const isInRange = now.isBetween(startTime, endTime, null, '[)');
    // console.log(':', isInRange);
    return isInRange;
} }
// isBetween // isBetween
function emitEvent(emitName) { function emitEvent(emitName) {
if (isGoods()) { if (isGoods()) {
emits(emitName, props.index) emits(emitName, props.index);
} }
} }
</script> </script>
@ -251,7 +354,7 @@ function isProductAvailable(sellDaysStr, startTimeStr, endTimeStr) {
} }
.btn { .btn {
background: #EB4F4F; background: #eb4f4f;
border-radius: 100rpx; border-radius: 100rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
@ -260,23 +363,19 @@ function isProductAvailable(sellDaysStr, startTimeStr, endTimeStr) {
} }
.btn-hover-class { .btn-hover-class {
opacity: .6; opacity: 0.6;
} }
.item { .item {
// width: 250rpx; // width: 250rpx;
// height: 272rpx; // height: 272rpx;
background: #F9B798; background: #f9b798;
border-radius: 12px; border-radius: 12px;
overflow: hidden; overflow: hidden;
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
&.default {
.img {}
}
.img { .img {
position: absolute; position: absolute;
left: 0; left: 0;
@ -304,7 +403,24 @@ function isProductAvailable(sellDaysStr, startTimeStr, endTimeStr) {
overflow: hidden; overflow: hidden;
z-index: 2; z-index: 2;
} }
.limit-discount {
background-color: #cc5617;
padding: 10rpx 20rpx;
white-space: nowrap;
text-align: center;
position: absolute;
top: 0;
left: 0;
font-weight: 400;
font-size: 28rpx;
color: #ffffff;
border-radius: 20rpx 0rpx 20rpx 0rpx;
z-index: 9;
color: #fff;
}
}
.old-price {
text-decoration: line-through;
color: #999;
} }
</style> </style>

View File

@ -1,15 +1,23 @@
<template> <template>
<my-model ref="model" borderRadius="12" :title="title" width="50vw"> <my-model ref="model" borderRadius="12" :title="title" width="50vw">
<template #desc> <template #desc>
<scroll-view scroll-y="true" style="height: 50vh;" class="u-p-30 guigeModel"> <scroll-view
scroll-y="true"
style="height: 50vh"
class="u-p-30 guigeModel"
>
<view class="u-m-b-40" v-for="(item, index) in skus" :key="index"> <view class="u-m-b-40" v-for="(item, index) in skus" :key="index">
<view class="u-text-left"> <view class="u-text-left">
<view class="color-333">{{ item.name }}</view> <view class="color-333">{{ item.name }}</view>
</view> </view>
<view class="u-flex u-m-t-20 u-flex-wrap"> <view class="u-flex u-m-t-20 u-flex-wrap">
<view class="item" @tap="chooseSkd(index,skd)" <view
class="item"
@tap="chooseSkd(index, skd)"
:class="{ active: item.sel === skd.name, disabled: skd.disabled }" :class="{ active: item.sel === skd.name, disabled: skd.disabled }"
v-for="(skd,skdIndex) in item.values" :key="skdIndex"> v-for="(skd, skdIndex) in item.values"
:key="skdIndex"
>
{{ skd.name }} {{ skd.name }}
</view> </view>
</view> </view>
@ -21,20 +29,28 @@
<view class="u-flex u-p-b-30 u-row-between"> <view class="u-flex u-p-b-30 u-row-between">
<view class="price"> <view class="price">
<template v-if="goods && goods.isGrounding"> <template v-if="goods && goods.isGrounding">
<text></text> <text v-if="goodsData.is_time_discount">{{ returnLimitPrice() }}</text>
<text>{{to2(goods.salePrice*number) }}</text> <text :class="{'old-price':goodsData.is_time_discount}">{{ to2(goods.salePrice * number) }}</text>
</template> </template>
</view> </view>
<view class="u-flex"> <view class="u-flex">
<view class="u-flex" @tap="reduce"> <view class="u-flex" @tap="reduce">
<image src="/pagesCreateOrder/static/images/icon-reduce-black.svg" class="icon" mode=""> <image
src="/pagesCreateOrder/static/images/icon-reduce-black.svg"
class="icon"
mode=""
>
</image> </image>
</view> </view>
<view class="u-m-l-30 u-m-r-30 color-333"> <view class="u-m-l-30 u-m-r-30 color-333">
{{ number }} {{ number }}
</view> </view>
<view class="u-flex" @tap="add"> <view class="u-flex" @tap="add">
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" class="icon" mode=""> <image
src="/pagesCreateOrder/static/images/icon-add-black.svg"
class="icon"
mode=""
>
</image> </image>
</view> </view>
</view> </view>
@ -51,165 +67,178 @@
</template> </template>
<script setup> <script setup>
import { import { computed, reactive, ref, watch,inject } from "vue";
computed, import util from "../util.js";
reactive, import infobox from "@/commons/utils/infoBox.js";
ref, import myModel from "@/components/my-components/my-model.vue";
watch import myButton from "@/components/my-components/my-button.vue";
} from 'vue'; import BigNumber from "bignumber.js";
import util from '../util.js'; const yskUtils = inject("yskUtils");
import infobox from '@/commons/utils/infoBox.js' const shopInfo = uni.getStorageSync("shopInfo");
import myModel from '@/components/my-components/my-model.vue'
import myButton from '@/components/my-components/my-button.vue'
const props = defineProps({ const props = defineProps({
limitTimeDiscount:{
type: Object,
default: () => {
return {};
},
},
goodsData: { goodsData: {
type: Object, type: Object,
default: () => {} default: () => {},
}, },
title: { title: {
type: String, type: String,
default: '' default: "",
}, },
skuMap: { skuMap: {
type: Object, type: Object,
default: () => { default: () => {
return {} return {};
} },
}, },
skus: { skus: {
type: Array, type: Array,
default: () => { default: () => {
return [] return [];
} },
}, },
defaultIndex: { defaultIndex: {
type: Array, type: Array,
default: () => { default: () => {
return [] return [];
} },
} },
}) });
function to2(number) { function to2(number) {
return Number(number).toFixed(2) return Number(number).toFixed(2);
} }
function returnLimitPrice(){
const price= yskUtils.limitUtils.returnPrice({
goods: goods.value,
shopInfo: shopInfo,
limitTimeDiscountRes: props.limitTimeDiscount,
shopUserInfo: null,
idKey: "id",
});
return BigNumber(price).times(number.value).toNumber()
}
const selSku = computed(() => { const selSku = computed(() => {
return props.skus.reduce((prve, cur) => { return props.skus
prve.push(cur.sel) .reduce((prve, cur) => {
return prve prve.push(cur.sel);
}, []).join() return prve;
}) }, [])
.join();
});
const goods = computed(() => { const goods = computed(() => {
return props.skuMap[selSku.value] return props.skuMap[selSku.value];
}) });
watch(() => goods.value, (newval) => { watch(
() => goods.value,
(newval) => {
console.log(props.goodsData.isStock); console.log(props.goodsData.isStock);
number.value = newval.suit || 1 number.value = newval.suit || 1;
}) }
);
const isCanBuy = computed(() => { const isCanBuy = computed(() => {
if (!goods.value) { if (!goods.value) {
return false return false;
} }
console.log(util.isCanBuy({ console.log(
util.isCanBuy({
...goods.value, ...goods.value,
isStock: props.goodsData.isStock isStock: props.goodsData.isStock,
})); })
);
return util.isCanBuy({ return util.isCanBuy({
...goods.value, ...goods.value,
isStock: props.goodsData.isStock isStock: props.goodsData.isStock,
}) });
});
})
//使 //使
const isAllDisabled = computed(() => { const isAllDisabled = computed(() => {
console.log(props.skus); console.log(props.skus);
return props.skus.reduce((prve, cur) => { return props.skus.reduce((prve, cur) => {
return prve && cur.values.filter(v => v.disabled).length === cur.values.length return (
}, true) prve && cur.values.filter((v) => v.disabled).length === cur.values.length
}) );
}, true);
const emits = defineEmits(['confirm', 'updateSku']) });
let number = ref(1)
const emits = defineEmits(["confirm", "updateSku"]);
let number = ref(1);
function chooseSkd(skusIndex, skd) { function chooseSkd(skusIndex, skd) {
const { const { name, disabled } = skd;
name,
disabled
} = skd
if (disabled) { if (disabled) {
return return;
} }
if (props.skus[skusIndex].sel != name) { if (props.skus[skusIndex].sel != name) {
emits('updateSku', skusIndex, name) emits("updateSku", skusIndex, name);
} }
} }
const defaultIndex = reactive(new Array(props.skus.length).fill('')) const defaultIndex = reactive(new Array(props.skus.length).fill(""));
for (let i in props.defaultIndex) { for (let i in props.defaultIndex) {
defaultIndex[i] = props.defaultIndex[i] defaultIndex[i] = props.defaultIndex[i];
} }
const activeArr = defaultIndex const activeArr = defaultIndex;
const model = ref(null);
const model = ref(null)
function open() { function open() {
model.value.open() model.value.open();
} }
function close() { function close() {
model.value.close() model.value.close();
} }
const isDisabled = computed(() => { const isDisabled = computed(() => {
return isAllDisabled.value || !isCanBuy.value return isAllDisabled.value || !isCanBuy.value;
}) });
function reduce() { function reduce() {
if (isDisabled.value) { if (isDisabled.value) {
return return;
} }
const suit = goods.value.suit || 1 const suit = goods.value.suit || 1;
const newval = number.value - 1 const newval = number.value - 1;
if (newval < suit) { if (newval < suit) {
return infobox.showToast(suit + '个起售') return infobox.showToast(suit + "个起售");
} }
number.value = newval <= 1 ? 1 : newval number.value = newval <= 1 ? 1 : newval;
} }
function add() { function add() {
if (isDisabled.value) { if (isDisabled.value) {
return return;
} }
const newval = number.value + 1 const newval = number.value + 1;
number.value = newval number.value = newval;
} }
function confirm() { function confirm() {
close() close();
if (isDisabled.value) { if (isDisabled.value) {
return return;
} }
emits('confirm', goods.value, number.value) emits("confirm", goods.value, number.value);
} }
defineExpose({ defineExpose({
open, open,
close close,
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.border-top {} .border-top {
}
.icon { .icon {
width: 60rpx; width: 60rpx;
@ -221,11 +250,11 @@
color: #666; color: #666;
font-size: 28rpx; font-size: 28rpx;
padding: 4rpx 28rpx; padding: 4rpx 28rpx;
border: 1px solid #E5E5E5; border: 1px solid #e5e5e5;
border-radius: 8rpx; border-radius: 8rpx;
margin-right: 20rpx; margin-right: 20rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
transition: all .2s ease-in-out; transition: all 0.2s ease-in-out;
&.active { &.active {
border-color: $my-main-color; border-color: $my-main-color;
@ -240,10 +269,14 @@
} }
.price { .price {
color: #EB4F4F; color: #eb4f4f;
} }
.border-top { .border-top {
border-top: 1px solid #E5E5E5; border-top: 1px solid #e5e5e5;
}
.old-price{
color: #999;
text-decoration: line-through;
} }
</style> </style>

File diff suppressed because it is too large Load Diff

View File

@ -98,8 +98,8 @@
*/ */
function getShopInfoData () { function getShopInfoData () {
getShopInfo({id:uni.getStorageSync('shopInfo').id}).then(res=>{ getShopInfo({id:uni.getStorageSync('shopInfo').id}).then(res=>{
pageData.shopInfo = res; pageData.shopInfo = res.data;
uni.setStorageSync('shopInfo',res) uni.setStorageSync('shopInfo',res.data)
}) })
} }

File diff suppressed because it is too large Load Diff

888
pagesOrder/quan/coupon.ts Normal file
View File

@ -0,0 +1,888 @@
import { BigNumber } from "bignumber.js";
import _ from "lodash";
export interface Goods {
productId: string | number; // 商品ID唯一标识商品用于优惠券/活动匹配,必选)
skuId: string | number; // 商品规格ID唯一标识商品规格如颜色/尺寸)
id: string | number; // 购物车ID唯一标识购物车中的条目如购物车项主键
product_id: string | number; // 商品ID唯一标识商品用于优惠券/活动匹配,必选)
salePrice: number; // 商品原价(元)
number: number; // 商品数量
product_type: string; // 商品类型
is_temporary?: number; // 是否临时菜默认false
is_gift?: number; // 是否赠菜默认false
returnNum?: number; // 退货数量历史订单用默认0
memberPrice: number; // 商品会员价(元,优先级:商品会员价 > 会员折扣)
discountSaleAmount?: number; // 商家改价后单价(元,优先级最高)
packFee?: number; // 单份打包费默认0
packNumber?: number; // 堂食打包数量默认0
skuData?: {
// SKU扩展数据可选
id: string | number; // SKU ID唯一标识商品规格如颜色/尺寸)
memberPrice?: number; // SKU会员价
salePrice?: number; // SKU原价
};
discount_sale_amount: number; // 商家改价后单价(元,优先级最高)
[property: string]: any;
}
export interface User {
isVip: number; // 是否会员 1是会员
[property: string]: any;
}
export interface ShopInfo {
isMemberPrice: number; // 是否开启会员价 1是开启
[property: string]: any;
}
export interface ThresholdFood {
id: string | number; // 商品ID
[property: string]: any;
}
export interface UseFood {
id: string | number;
[property: string]: any;
}
export interface Coupon {
id: string | number;
use: boolean;
type: number;
thresholdFoods: ThresholdFood[];
useFoods: UseFood[];
noUseRestrictions?: string;
discountShare: number; // 是否与折扣优惠同享 1是同享
vipPriceShare: number; // 是否与会员优惠同享 1是同享
otherCouponShare: number; // 是否与其他优惠券同享 1是同享
fullAmount: number; // 使用门槛金额
discountRate: number; // 折扣率(满减券:折扣金额/门槛金额,折扣券:折扣率)
maxDiscountAmount: number; // 最大折扣金额(满减券:折扣金额,折扣券:折扣金额)
discountNum: number; // 抵扣商品数量商品券抵扣商品数量折扣券0
useRule: string; // 使用规则price_asc按商品单价升序price_desc按商品单价降序
}
export interface couponDiscount {
discountPrice: number;
hasDiscountGoodsArr: Goods[];
}
export interface selCoupon extends Coupon {
discount?: couponDiscount;
}
export interface couponCalcParams {
canDikouGoodsArr: Goods[];
coupon: Coupon;
user: User;
shopInfo: ShopInfo;
selCoupon: selCoupon[];
goodsOrderPrice: number; //商品订单总价
isMemberPrice: number; // 是否开启会员价 1是开启
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined;
}
//限时折扣配置
export interface TimeLimitDiscountConfig {
/**
* limit-time/vip-price
*/
discountPriority: string;
/**
* % 1-99
*/
discountRate: number;
/**
*
*/
foods: string;
/**
* 1 2
*/
foodType: number;
/**
*
*/
id: number;
/**
* ID
*/
shopId: number;
/**
* 使 dine-in take-out take-away post
*/
useType: string;
[property: string]: any;
}
export interface CanDikouGoodsArrArgs {
canDikouGoodsArr: Goods[];
selCoupon: selCoupon[];
user: User;
shopInfo: ShopInfo;
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined;
}
/**
*
* @param goods
* @param user
* @param {Object} shopInfo
*/
export function returnGoodsPrice(
goods: Goods,
user: User,
shopInfo: ShopInfo,
limitTimeDiscount: TimeLimitDiscountConfig | null | undefined
) {
if (!goods) {
return 0;
}
//是否可以使用会员价
const canUseVipPrice =
user &&
user.isVip &&
user.isMemberPrice &&
goods.memberPrice * 1 > 0 &&
shopInfo &&
shopInfo.isMemberPrice;
// 商家改价
if (goods.discount_sale_amount * 1 > 0) {
return goods.salePrice;
}
// 限时折扣
if (limitTimeDiscount && limitTimeDiscount.id) {
const canUseFoods = limitTimeDiscount.foods.split(",");
const canUseLimit =
limitTimeDiscount.foodType == 1 ||
canUseFoods.includes(`${goods.productId}`);
if (canUseLimit && limitTimeDiscount.discountPriority == "limit-time") {
return new BigNumber(goods.salePrice)
.times(limitTimeDiscount.discountRate / 100)
.decimalPlaces(2, BigNumber.ROUND_UP)
.toNumber();
}
if (canUseLimit && limitTimeDiscount.discountPriority == "vip-price") {
if (canUseVipPrice) {
return goods.memberPrice;
} else {
return new BigNumber(goods.salePrice)
.times(limitTimeDiscount.discountRate / 100)
.decimalPlaces(2, BigNumber.ROUND_UP)
.toNumber();
}
}
}
if (canUseVipPrice) {
return goods.memberPrice;
}
return goods.salePrice;
}
/**
*
* @param arr
*/
export function returnGoodsGroupMap(arr: Goods[]) {
let map: { [key: string]: Goods[] } = {};
arr.forEach((v) => {
const key = v.productId + "_" + v.skuId;
if (!map[key]) {
map[key] = [];
}
map[key].push(v);
});
return map;
}
/**
* 1-2-3-4-5-6-7-8-
* @param coupon
*/
export function returnCoupType(coupon: Coupon) {
const couponTypes = {
1: "满减券",
2: "商品券",
3: "折扣券",
4: "第二件半价券",
5: "消费送券",
6: "买一送一券",
7: "固定价格券",
8: "免配送费券",
};
return couponTypes[coupon.type as keyof typeof couponTypes] || "未知类型";
}
/**
*
* @param canDikouGoodsArr
* @param selCoupon
* @param user
*/
export function returnCanDikouGoodsArr(args: CanDikouGoodsArrArgs) {
const { canDikouGoodsArr, selCoupon, user, shopInfo, limitTimeDiscount } =
args;
const types = [2, 4, 6];
// 收集已抵扣商品并关联对应的优惠券类型
const goodsCouponGoods = selCoupon
.filter((v) => types.includes(v.type))
.reduce((prev: Goods[], cur) => {
// 给每个抵扣商品添加所属优惠券类型
if (cur && cur.discount) {
const goodsWithType = cur.discount.hasDiscountGoodsArr.map((goods) => ({
...goods,
couponType: cur.type, // 记录该商品是被哪种类型的优惠券抵扣的
}));
prev.push(...goodsWithType);
}
return prev;
}, []);
const arr = _.cloneDeep(canDikouGoodsArr)
.map((v) => {
const findCart = goodsCouponGoods.find((carts) => carts.id == v.id);
if (findCart) {
// 根据优惠券类型判断扣减数量
if ([4, 6].includes(findCart.couponType)) {
// 类型4第二件半价或6买一送一数量减2
v.num -= 2;
} else {
// 其他类型如类型2商品券按原逻辑扣减对应数量
v.num -= findCart.num;
}
}
return v;
})
.filter((v) => {
const canUseNum = v.num - (v.returnNum || 0);
if (canUseNum <= 0 || v.is_temporary == 1 || v.is_gift == 1) {
return false;
}
return true;
}); // 过滤掉数量<=0的商品,赠菜,临时菜
return arr;
}
/**
* /
* @param {*} goods
*/
function returnGoodsIsUseVipPrice(shopInfo: ShopInfo, user: User, goods: Goods) {
if (goods.is_time_discount) {
return false;
}
if (shopInfo.isMemberPrice != 1 || user.isVip != 1) {
return false;
}
if (shopInfo.isMemberPrice == 1 && user.isVip == 1) {
console.log('goods', goods);
if (goods.memberPrice <= 0) {
return false;
}else{
return true;
}
}
return false
}
/**
*
*/
function returnCanCalcGoodsList(canCalcGoodsArr: Goods[], coupon: Coupon, shopInfo: ShopInfo, user: User) {
return canCalcGoodsArr.filter((goods) => {
if (
!coupon.discountShare &&
(goods.is_time_discount || goods.isTimeDiscount)
) {
return false;
}
if (
!coupon.vipPriceShare &&
returnGoodsIsUseVipPrice(shopInfo, user, goods)
) {
return false;
}
return true;
});
}
/**
* 使
*
* @param {Object} args -
* @param {Array} args.canDikouGoodsArr -
* @param {Object} args.coupon -
* @param {boolean} args.coupon.use -
* @param {Array} args.coupon.useFoods - ID列表
* @param {number} args.coupon.fullAmount - 使
* @param {number} args.coupon.type -
* @param {number} args.goodsOrderPrice -
* @param {Object} args.user -
* @param {Object} args.selCoupon -
* @param {Object} args.shopInfo
* @param {boolean} args.limitTimeDiscount -
* @returns {Object} - { canUse: boolean, reason: string }
*/
export function returnCouponCanUse(args: couponCalcParams) {
let {
canDikouGoodsArr,
coupon,
goodsOrderPrice,
user,
selCoupon,
shopInfo,
isMemberPrice,
limitTimeDiscount,
} = args;
// 优惠券未启用
if (!coupon.use) {
return {
canUse: false,
reason: coupon.noUseRestrictions || "不在可用时间段内",
};
}
if (
limitTimeDiscount &&
limitTimeDiscount.id &&
limitTimeDiscount.foodType == 1 &&
!coupon.discountShare
) {
return {
canUse: false,
reason: coupon.noUseRestrictions || "不可与限时折扣同享",
};
}
// 计算门槛金额
let fullAmount = goodsOrderPrice;
canDikouGoodsArr = returnCanDikouGoodsArr(args);
//优惠券指定门槛商品列表
let canCalcGoodsArr = [...canDikouGoodsArr];
//部分商品参与门槛计算
if (coupon.thresholdFoods.length) {
canCalcGoodsArr = canDikouGoodsArr.filter((v) => {
return coupon.thresholdFoods.find((food) => food.id == v.productId);
});
}
console.log("canCalcGoodsArr",canCalcGoodsArr);
canCalcGoodsArr = returnCanCalcGoodsList(
canCalcGoodsArr,
coupon,
shopInfo,
user
);
fullAmount = canCalcGoodsArr.reduce((pre, cur) => {
return (
pre + returnGoodsPrice(cur, user, shopInfo, limitTimeDiscount) * cur.num
);
}, 0);
// 是否全部商品可用
const isDikouAll = coupon.useFoods.length === 0;
// 订单可用商品列表
let canUseGoodsArr: Goods[] = [];
if (!isDikouAll) {
canUseGoodsArr = canDikouGoodsArr.filter((v) => {
return coupon.useFoods.find((food) => food.id == v.productId);
});
}
// if (user.isVip && !coupon.vipPriceShare) {
// return {
// canUse: false,
// reason: "非会员可用",
// };
// }
if (selCoupon.length > 0 && !selCoupon[0].otherCouponShare) {
return {
canUse: false,
reason: "当前选中的券不可与其他券同享",
};
}
if (selCoupon.length > 0 && !coupon.otherCouponShare) {
return {
canUse: false,
reason: "当前选中的券不可与其他券同享",
};
}
// 满减券和折扣券计算门槛金额是否满足
if ([1, 3].includes(coupon.type)) {
if (canCalcGoodsArr.length <= 0) {
return {
canUse: false,
reason: "没有可参与计算门槛的商品",
};
}
// 不满足门槛金额
if (fullAmount < coupon.fullAmount) {
return {
canUse: false,
reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}`,
};
}
}
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
if ([2, 4, 5].includes(coupon.type)) {
if(coupon.type==2){
console.log("isDikouAll",isDikouAll);
console.log("canCalcGoodsArr",canCalcGoodsArr);
}
// 没有符合条件的商品
if (isDikouAll && canDikouGoodsArr.length === 0) {
return {
canUse: false,
reason: "没有符合条件的商品",
};
}
if (!isDikouAll && canUseGoodsArr.length === 0) {
return {
canUse: false,
reason: "没有符合条件的商品",
};
}
if (coupon.type == 2) {
if (canCalcGoodsArr.length <= 0) {
return {
canUse: false,
reason: "没有符合计算门槛条件的商品",
};
}
if (fullAmount < coupon.fullAmount) {
return {
canUse: false,
reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}`,
};
}
}
}
//商品兑换券是否达到门槛金额
if (coupon.type == 2 && goodsOrderPrice < coupon.fullAmount) {
return {
canUse: false,
reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}`,
};
}
// 买一送一券特殊验证
if (coupon.type === 6) {
let canUse = false;
if (isDikouAll) {
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
} else if (canUseGoodsArr.length > 0) {
canUse = canUseGoodsArr.some((v) => v.num >= 2);
}
if (!canUse) {
return {
canUse: false,
reason: "需要购买至少2件相同的商品才能使用",
};
}
}
// 第二件半价券特殊验证
if (coupon.type === 4) {
let canUse = false;
if (isDikouAll) {
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
} else if (canUseGoodsArr.length > 0) {
canUse = canUseGoodsArr.some((v) => v.num >= 2);
}
if (!canUse) {
return {
canUse: false,
reason: "需要购买至少2件相同的商品才能使用",
};
}
}
// 所有条件都满足
return {
canUse: true,
reason: "",
};
}
/**
*
* @param discountGoodsArr
* @param discountNum
* @param user
* @param {Object} shopInfo
*/
export function calcDiscountGoodsArrPrice(
discountGoodsArr: Goods[],
discountNum: number,
user: User,
shopInfo: ShopInfo,
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined
) {
let hasCountNum = 0;
let discountPrice = 0;
let hasDiscountGoodsArr = [];
for (let i = 0; i < discountGoodsArr.length; i++) {
if (hasCountNum >= discountNum) {
break;
}
const goods = discountGoodsArr[i];
const shengyuNum = discountNum - hasCountNum;
const num = Math.min(goods.num, shengyuNum);
const realPrice = returnGoodsPrice(
goods,
user,
shopInfo,
limitTimeDiscount
);
discountPrice += realPrice * num;
hasCountNum += num;
hasDiscountGoodsArr.push({
...goods,
num,
});
}
return {
discountPrice,
hasDiscountGoodsArr,
};
}
/**
*
* @param arr
* @param coupon
* @param user
* @param goodsOrderPrice
* @param selCoupon
* @param shopInfo
* @param limitTimeDiscount
*/
export function returnCouponDiscount(
arr: Goods[],
coupon: Coupon,
user: User,
goodsOrderPrice: number,
selCoupon: selCoupon[],
shopInfo: ShopInfo,
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined
) {
arr = returnCanDikouGoods(arr, user, shopInfo,limitTimeDiscount);
const canDikouGoodsArr = returnCanDikouGoodsArr({
canDikouGoodsArr: arr,
selCoupon,
user,
shopInfo,
limitTimeDiscount,
});
if (coupon.type == 2) {
return returnCouponProductDiscount(
canDikouGoodsArr,
coupon,
user,
shopInfo,
limitTimeDiscount
);
}
if (coupon.type == 6) {
const result = returnCouponBuyOneGiveOneDiscount(
canDikouGoodsArr,
coupon,
user,
shopInfo,
limitTimeDiscount
);
return result;
}
if (coupon.type == 4) {
return returnSecoendDiscount(
canDikouGoodsArr,
coupon,
user,
shopInfo,
limitTimeDiscount
);
}
if (coupon.type == 3) {
return returnCouponZhekouDiscount(
canDikouGoodsArr,
coupon,
user,
goodsOrderPrice,
selCoupon,
limitTimeDiscount
);
}
}
/**
*
* @param canDikouGoodsArr
* @param coupon
* @param user
* @param goodsOrderPrice
* @param selCoupon
* @param limitTimeDiscount
*/
export function returnCouponZhekouDiscount(
canDikouGoodsArr: Goods[],
coupon: Coupon,
user: User,
goodsOrderPrice: number,
selCoupon: selCoupon[],
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined
) {
const { discountRate, maxDiscountAmount } = coupon;
// 计算商品优惠券折扣总和使用BigNumber避免精度问题
const goodsCouponDiscount = selCoupon
.filter((v) => v.type == 2)
.reduce((prve, cur) => {
return new BigNumber(prve).plus(
new BigNumber(cur?.discount?.discountPrice || 0)
);
}, new BigNumber(0));
// 将商品订单价格转换为BigNumber并减去优惠券折扣
const adjustedGoodsOrderPrice = new BigNumber(goodsOrderPrice).minus(
goodsCouponDiscount
);
// 计算优惠比例:(100 - 折扣率) / 100
const discountAmountRatio = new BigNumber(100)
.minus(discountRate)
.dividedBy(100);
// 计算折扣金额:调整后的商品订单金额 × 优惠比例
let discountPrice = adjustedGoodsOrderPrice
.times(discountAmountRatio)
.decimalPlaces(2, BigNumber.ROUND_FLOOR)
.toNumber();
// 应用最大折扣金额限制
if (maxDiscountAmount !== 0) {
discountPrice =
discountPrice >= maxDiscountAmount ? maxDiscountAmount : discountPrice;
}
return {
discountPrice, // 折扣抵扣金额(即优惠的金额)
hasDiscountGoodsArr: [],
};
}
/**
*
* @param canDikouGoodsArr
* @param coupon
* @param user
* @param shopInfo
*/
export function returnCouponProductDiscount(
canDikouGoodsArr: Goods[],
coupon: Coupon,
user: User,
shopInfo: ShopInfo,
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined
) {
const { useFoods, discountNum, useRule } = coupon;
//抵扣商品数组
let discountGoodsArr = [];
//抵扣全部商品
if (useFoods.length === 0) {
if (useRule == "price_asc") {
discountGoodsArr = canDikouGoodsArr.slice(discountNum * -1).reverse();
} else {
discountGoodsArr = canDikouGoodsArr.slice(0, discountNum);
}
} else {
//抵扣选中商品
const discountSelGoodsArr = canDikouGoodsArr.filter((v) =>
useFoods.find((food) => food.id == v.productId)
);
if (useRule == "price_asc") {
discountGoodsArr = discountSelGoodsArr.slice(discountNum * -1).reverse();
} else {
discountGoodsArr = discountSelGoodsArr.slice(0, discountNum);
}
}
const result = calcDiscountGoodsArrPrice(
discountGoodsArr,
discountNum,
user,
shopInfo,
limitTimeDiscount
);
return result;
}
// 返回买一送一券抵扣详情
/**
* @param canDikouGoodsArr
* @param coupon
* @param user
* @param shopInfo
*/
function returnCouponBuyOneGiveOneDiscount(
canDikouGoodsArr: Goods[],
coupon: Coupon,
user: User,
shopInfo: ShopInfo,
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined
) {
const { useFoods, useRule } = coupon;
//抵扣商品
let discountGoods = undefined;
//符合买一送一条件的商品
const canUseGoods = canDikouGoodsArr.filter((v) => v.num >= 2);
//抵扣全部商品
if (useFoods.length === 0) {
if (useRule == "price_asc") {
discountGoods = canUseGoods[canUseGoods.length - 1];
} else {
discountGoods = canUseGoods[0];
}
} else {
//符合抵扣条件的商品
const canUseGoods1 = canUseGoods.filter((v) =>
useFoods.find((food) => food.id == v.productId)
);
if (useRule == "price_asc") {
discountGoods = canUseGoods1[canUseGoods1.length - 1];
} else {
discountGoods = canUseGoods1[0];
}
}
let discountPrice = 0;
let hasDiscountGoodsArr: Goods[] = [];
if (discountGoods) {
discountPrice = returnGoodsPrice(
discountGoods,
user,
shopInfo,
limitTimeDiscount
);
hasDiscountGoodsArr = [discountGoods];
}
return {
discountPrice: discountPrice <= 0 ? 0 : discountPrice,
hasDiscountGoodsArr,
};
}
/**
*
* @param canDikouGoodsArr
* @param coupon
* @param user
* @param shopInfo
*/
function returnSecoendDiscount(
canDikouGoodsArr: Goods[],
coupon: Coupon,
user: User,
shopInfo: ShopInfo,
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined
) {
const { useFoods, useRule } = coupon;
//抵扣商品
let discountGoods = undefined;
//符合条件的商品
const canUseGoods = canDikouGoodsArr.filter((v) => v.num >= 2);
//抵扣全部商品
if (useFoods.length === 0) {
if (useRule == "price_asc") {
discountGoods = canUseGoods[canUseGoods.length - 1];
} else {
discountGoods = canUseGoods[0];
}
} else {
//符合抵扣条件的商品
const canUseGoods1 = canUseGoods.filter((v) =>
useFoods.find((food) => food.id == v.productId)
);
if (useRule == "price_asc") {
discountGoods = canUseGoods1[canUseGoods1.length - 1];
} else {
discountGoods = canUseGoods1[0];
}
}
let discountPrice = 0;
let hasDiscountGoodsArr: Goods[] = [];
if (discountGoods) {
discountPrice = returnGoodsPrice(
discountGoods,
user,
shopInfo,
limitTimeDiscount
);
hasDiscountGoodsArr = [discountGoods];
}
//返回半价价格
return {
discountPrice:
discountPrice <= 0
? 0
: new BigNumber(discountPrice).dividedBy(2).toNumber(),
hasDiscountGoodsArr,
};
}
/**
* ,,
* @param arr
* @param user
* @param shopInfo
* @param limitTimeDiscount
*/
export function returnCanDikouGoods(
arr: Goods[],
user: User,
shopInfo: ShopInfo,
limitTimeDiscount?: TimeLimitDiscountConfig | null | undefined
) {
const result = arr
.filter((v) => {
return v.is_temporary != 1 && v.is_gift != 1;
})
.filter((v) => {
return v.num > 0;
})
.sort((a, b) => {
return (
returnGoodsPrice(b, user, shopInfo, limitTimeDiscount) -
returnGoodsPrice(a, user, shopInfo, limitTimeDiscount)
);
});
return result;
}
export const utils = {
returnGoodsPrice,
returnGoodsGroupMap,
returnCoupType,
returnCanDikouGoods,
returnCanDikouGoodsArr,
returnCouponCanUse,
calcDiscountGoodsArrPrice,
returnCouponDiscount,
returnCouponProductDiscount,
returnCouponZhekouDiscount,
};
export default utils;

View File

@ -4,24 +4,38 @@
<my-tabs v-model="myQuan.types.sel" :list="myQuan.types.list"></my-tabs> <my-tabs v-model="myQuan.types.sel" :list="myQuan.types.list"></my-tabs>
</up-sticky> </up-sticky>
<view class="u-m-t-32"> <view class="u-m-t-32">
<template v-if="myQuan.types.sel==0"> <view
<view class="" @click="changeFullReductionCouponSel(item)" class=""
v-for="(item,index) in myQuan.res.fullReductionCoupon" :class="{filtergray:!item.use}" :key="index"> @click="changeSelCoupon(item)"
<view class="quan u-row-between u-flex u-col-center u-m-b-32 border-r-10 "> v-for="(item, index) in list.canUseCoupons"
:class="{ filtergray: !item.use }"
:key="index"
>
<view
class="quan u-row-between u-flex u-col-center u-m-b-32 border-r-10"
>
<view class="no-use" v-if="!item.use"> <view class="no-use" v-if="!item.use">
<image class="img" src="/pagesOrder/static/image/no-use.svg" mode=""></image> <image
class="img"
src="/pagesOrder/static/image/no-use.svg"
mode=""
></image>
</view> </view>
<view class="sel u-abso" v-if="item.id==myQuan.fullReductionCouponSel.id "> <view class="sel u-abso" v-if="isActive(item)">
<up-icon name="checkbox-mark" color="#fff"></up-icon> <up-icon name="checkbox-mark" color="#fff"></up-icon>
</view> </view>
<view class="u-p-t-32 u-p-b-32 u-p-l-24 u-p-r-24 left"> <view class="u-p-t-32 u-p-b-32 u-p-l-24 u-p-r-24 left">
<view class="u-flex"> <view class="u-flex" v-if="item.type != 2">
<view class="hui"></view> <view class="hui"></view>
<view class="u-m-l-18">{{ item.name }}</view> <view class="u-m-l-18">{{ item.name }}</view>
</view> </view>
<view v-else>{{ item.name }}</view>
<view class="u-m-t-20 u-flex"> <view class="u-m-t-20 u-flex">
<view>有效期:</view> <view>有效期:</view>
<view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }} <view class="u-font-24 u-m-l-6">
{{ dayjs(item.effectStartTime).format("YYYY-MM-DD HH:mm:ss") }}
-
{{ dayjs(item.effectEndTime).format("YYYY-MM-DD HH:mm:ss") }}
</view> </view>
</view> </view>
<view class="u-m-t-10 color-999 u-font-24"> <view class="u-m-t-10 color-999 u-font-24">
@ -29,72 +43,86 @@
</view> </view>
</view> </view>
<view class="right u-flex u-flex-col u-row-between"> <view class="right u-flex u-flex-col u-row-between">
<view class="u-flex u-row-center u-font-36 "> <view class="u-flex u-row-center u-font-36" v-if="item.type != 2">
{{ item.discountAmount }} {{ item.discountAmount }}
</view> </view>
<view class="u-flex u-font-24"> <view class="u-flex u-font-24"> {{ item.fullAmount }}可用 </view>
{{item.fullAmount}}可用
</view>
<view class="u-flex"> <view class="u-flex">
<view class="use-btn" @click.stop="toEmitChooseQuan(item)">去使用</view> <view class="use-btn" @click.stop="toEmitChooseQuan(item)"
>去使用</view
>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<template v-if="myQuan.res.fullReductionCoupon.length<=0&&myQuan.hasAjax"> <template v-if="list.canUseCoupons.length <= 0 && myQuan.hasAjax">
<my-img-empty tips="暂无可用优惠券"></my-img-empty> <my-img-empty tips="暂无可用优惠券"></my-img-empty>
</template> </template>
</template> <view style="height: 40rpx"></view>
<view
<template v-if="myQuan.types.sel==1"> v-for="(item, index) in list.noCanUseCoupons"
<view class="" @click="changeProductCoupon(item)" v-for="(item,index) in myQuan.res.productCoupon" class="filtergray"
:class="{filtergray:!item.use}" :key="index"> :key="index"
<view class="quan goods u-row-between u-flex u-col-center u-m-b-32 border-r-10 u-relative"> >
<view class="no-use" v-if="!item.use"> <view
<image class="img" src="/pagesOrder/static/image/no-use.svg" mode=""></image> class="quan u-row-between u-flex u-col-center u-m-b-32 border-r-10"
>
<view class="no-use">
<image
class="img"
src="/pagesOrder/static/image/no-use.svg"
mode=""
></image>
</view> </view>
<view class="sel u-abso" v-if="item.checked"> <view class="sel u-abso" v-if="isActive(item)">
<up-icon name="checkbox-mark" color="#fff"></up-icon> <up-icon name="checkbox-mark" color="#fff"></up-icon>
</view> </view>
<view class="u-p-t-32 u-p-b-32 u-p-l-24 u-p-r-24 left"> <view class="u-p-t-32 u-p-b-32 u-p-l-24 u-p-r-24 left">
<view class="u-flex" v-if="item.type != 2">
<view class="hui"></view>
<view class="u-m-l-18">{{ item.name }}</view>
</view>
<template v-else>
<view class="u-flex"> <view class="u-flex">
<up-image width="80rpx" height="80rpx" :src="item.productCover"></up-image> {{ item.foods }}
<view class="u-m-l-18">
<view class="u-m-l-18">{{item.productName}}</view>
<view class="u-m-l-18 u-m-t-10 u-font-24 color-666">x{{item.num}}</view>
</view> </view>
<view class="u-flex">
{{ item.name }}
</view> </view>
<view class=" u-m-t-14 u-flex"> </template>
<view class="u-m-t-20 u-flex">
<view>有效期:</view> <view>有效期:</view>
<view class="u-font-24 u-m-l-6"> {{dayjs(item.endTime).format('YYYY-MM-DD HH:mm:ss') }} <view class="u-font-24 u-m-l-6">
{{ dayjs(item.effectStartTime).format("YYYY-MM-DD HH:mm:ss") }}
-
{{ dayjs(item.effectEndTime).format("YYYY-MM-DD HH:mm:ss") }}
</view> </view>
</view> </view>
<view class="u-m-t-10 color-999 u-font-24"> <view class="u-m-t-10 color-999 u-font-24">
{{ formatStr(item.useRestrictions) }} {{ formatStr(item.useRestrictions) }}
</view> </view>
<view class="u-m-t-10 color-999 u-font-24">
{{ returnNoUseRestrictions(item) }}
</view> </view>
<view class="right u-flex u-flex-col u-col-bottom u-row-center"> </view>
<!-- <view class="u-flex u-row-center w-full"> <view class="right u-flex u-flex-col u-row-between">
<view class="color-red font-bold u-m-b-24 ">{{item.discountAmount}}</view> <view class="u-flex u-row-center u-font-36" v-if="item.type != 2">
</view> --> {{ item.discountAmount }}
</view>
<view class="u-flex u-font-24"> {{ item.fullAmount }}可用 </view>
<view class="u-flex"> <view class="u-flex">
<view class="use-btn" @click.stop="toEmitChooseQuan(item)">去使用</view> <view class="use-btn" @click.stop="toEmitChooseQuan(item)"
>去使用</view
>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<template v-if="myQuan.res.productCoupon.length<=0&&myQuan.hasAjax">
<my-img-empty tips="暂无可用优惠券"></my-img-empty>
</template>
</template>
</view> </view>
<view :style="{ height: safebottomHeight + 'px' }"></view> <view :style="{ height: safebottomHeight + 'px' }"></view>
<view class="fixed-b bottom safe-bottom border-top"> <view class="fixed-b bottom safe-bottom border-top">
<view class="u-m-b-32 u-flex u-row-between u-p-t-10"> <view class="u-m-b-32 u-flex u-row-between u-p-t-10">
<view class="u-flex"> <view class="u-flex">
<text>抵扣金额</text> <text>抵扣金额</text>
@ -105,8 +133,11 @@
<text>支付金额</text> <text>支付金额</text>
<text class="color-red"></text> <text class="color-red"></text>
<text class="color-red">{{ payPrice }}</text> <text class="color-red">{{ payPrice }}</text>
<view class="u-absolute u-flex u-row-between" style="bottom: 100%;right: 0;" <view
v-if="payPrice*1!=option.orderPrice*1"> class="u-absolute u-flex u-row-between"
style="bottom: 100%; right: 0"
v-if="payPrice * 1 != option.orderPrice * 1"
>
<view class="u-flex line-th color-999"> <view class="u-flex line-th color-999">
<text class=""></text> <text class=""></text>
<text class="">{{ option.orderPrice }}</text> <text class="">{{ option.orderPrice }}</text>
@ -122,284 +153,448 @@
<view class="font-bold">确定</view> <view class="font-bold">确定</view>
</up-button> </up-button>
</view> </view>
</view> </view>
<up-modal :title="modal.title" :content="modal.content" :show="modal.clear" :confirmText="modal.confirmText" <up-modal
:cancelText="modal.cancelText" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm" :title="modal.title"
@cancel="confirmModelCancel" @close="setModalShow('clear',false)" width="300px" /> :content="modal.content"
:show="modal.clear"
:confirmText="modal.confirmText"
:cancelText="modal.cancelText"
showCancelButton
closeOnClickOverlay
@confirm="confirmModelConfirm"
@cancel="confirmModelCancel"
@close="setModalShow('clear', false)"
width="300px"
/>
</view> </view>
</template> </template>
<script setup> <script setup>
import { import { ref, reactive, watch, computed, onMounted, toRaw } from "vue";
ref, import couponUtils from "./coupon";
reactive, import color from "@/commons/color.js";
watch, import dayjs from "dayjs";
computed, import { getSafeBottomHeight } from "@/commons/utils/safe-bottom.js";
onMounted import go from "@/commons/utils/go.js";
} from 'vue'; import { onLoad, onReady } from "@dcloudio/uni-app";
import color from '@/commons/color.js' import * as orderApi from "@/http/yskApi/order.js";
import dayjs from 'dayjs'; import { $findCoupon } from "@/http/yskApi/Instead.js";
import { import infoBox from "@/commons/utils/infoBox.js";
getSafeBottomHeight import { queryAllShopUser, shopUserDetail } from "@/http/yskApi/shop-user.js";
} from '@/commons/utils/safe-bottom.js' // import {
import go from '@/commons/utils/go.js' // returnNewGoodsList,
import { // returnCoupCanUse,
onLoad, // returnCouponAllPrice,
onReady // returnProductCoupon,
} from '@dcloudio/uni-app' // returnCanUseFullReductionCoupon,
import * as orderApi from '@/http/yskApi/order.js' // } from "../quan_util.js";
import { // const yskUtils = {
$activateByOrderId // couponUtils,
} from '@/http/yskApi/Instead.js' // };
import infoBox from '@/commons/utils/infoBox.js' import yskUtils from "ysk-utils";
import {
queryAllShopUser
} from '@/http/yskApi/shop-user.js'
import {
returnNewGoodsList,
returnCoupCanUse,
returnCouponAllPrice,
returnProductCoupon,
returnCanUseFullReductionCoupon
} from '../quan_util.js'
const modal = reactive({ const modal = reactive({
title: '提示', title: "提示",
cancelText: '取消', cancelText: "取消",
confirmText: '确定', confirmText: "确定",
content: '', content: "",
key: '', key: "",
clear: false, clear: false,
data: '' data: "",
}) });
function confirmModelCancel() { function confirmModelCancel() {
setModalShow('clear', false, '') setModalShow("clear", false, "");
} }
async function confirmModelConfirm() { async function confirmModelConfirm() {
if (modal.key == 'clear') { if (modal.key == "clear") {
myQuan.fullReductionCouponSel = { myQuan.fullReductionCouponSel = {
id: '' id: "",
} };
const item = modal.data const item = modal.data;
item.checked = !item.checked item.checked = !item.checked;
const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked) const CheckedArr = myQuan.res.productCoupon.filter((v) => v.checked);
const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked) const noCheckedArr = myQuan.res.productCoupon.filter((v) => !v.checked);
noCheckedArr.map(v => { noCheckedArr.map((v) => {
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)); console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr) v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr);
}) });
setModalShow('clear', false, '') setModalShow("clear", false, "");
} }
} }
function setModalShow(key = 'show', show = true, data) { function setModalShow(key = "show", show = true, data) {
modal.key = key modal.key = key;
modal[key] = show modal[key] = show;
modal.data = data modal.data = data;
} }
function back() { function back() {
uni.navigateBack() uni.navigateBack();
} }
let order = ref({ let order = ref({});
let canDikouGoodsArr = [];
})
let canDikouGoodsArr = []
const myQuan = reactive({ const myQuan = reactive({
fullReductionCouponSel: { fullReductionCouponSel: {
id: '' id: "",
}, },
res: { res: {
fullReductionCoupon: [], fullReductionCoupon: [],
productCoupon: [] productCoupon: [],
}, },
types: { types: {
list: ['满减券(单选)', '商品券(多选)'], list: ["优惠券(单选)", "商品券(单选)"],
sel: 0 sel: 0,
}, },
list: [], list: [],
sel: -1, sel: -1,
hasAjax: false hasAjax: false,
}) });
function changeProductCoupon(item) { function changeSelCoupon(item) {
if (!item.use) { if (myQuan.types.sel == 0) {
return if (couponSel.value.id == item.id) {
} couponSel.value = {
if (myQuan.fullReductionCouponSel.id && !item.checked) { id: "",
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked) };
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : [] } else {
let coupArr = [...goodsQuan, item] couponSel.value = item;
const payPrice = option.orderPrice - returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
if (payPrice<=0) {
modal.content = '选择该商品券后支付金额将为0继续选择将取消选择的满减券'
modal.cancelText = '取消'
modal.confirmText = '继续选择'
setModalShow('clear', true, item)
return
}
if (myQuan.fullReductionCouponSel.fullAmount > payPrice) {
modal.content = '选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券'
modal.cancelText = '取消'
modal.confirmText = '继续选择'
setModalShow('clear', true, item)
return
}
}
item.checked = !item.checked
const CheckedArr = myQuan.res.productCoupon.filter(v => v.checked)
if (CheckedArr.length <= 0) {
return myQuan.res.productCoupon.map(v => {
v.use = true
})
}
const noCheckedArr = myQuan.res.productCoupon.filter(v => !v.checked)
noCheckedArr.map(v => {
console.log(returnCoupCanUse(canDikouGoodsArr, v, CheckedArr));
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
})
}
function changeFullReductionCouponSel(item) {
if (!item.use) {
return
}
console.log(item);
if (item.id == myQuan.fullReductionCouponSel.id) {
myQuan.fullReductionCouponSel = {
id: ''
} }
} else { } else {
myQuan.fullReductionCouponSel = item if (goodsCouponSel.value.id == item.id) {
goodsCouponSel.value = {
id: "",
};
} else {
goodsCouponSel.value = item;
}
} }
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, myQuan
.fullReductionCouponSel)
} }
function formatStr(str) { function formatStr(str) {
console.log(str); console.log(str);
if (!str) { if (!str) {
return '' return "";
} }
const reg = /^[,]+|[,]+$/g; const reg = /^[,]+|[,]+$/g;
return `${str}`.replace(reg, '') return `${str}`.replace(reg, "");
} }
function toUse(item) { function isActive(item) {
if (myQuan.types.sel == 0) {
return couponSel.value.id == item.id;
} else {
return goodsCouponSel.value.id == item.id;
}
}
const shopUserInfo = ref(null);
//
function returnAllGoodsList() {
let goodsArr = [];
for (let key in order.value.detailMap) {
console.log(order.value.detailMap[key]);
for (let goods of order.value.detailMap[key]) {
goods.salePrice = goods.salePrice || goods.price;
goods.number = goods.num || 0;
goodsArr.push(toRaw(goods));
}
}
return goodsArr;
}
//
function returnNoUseRestrictions(item) {
if (item.noUseRestrictions) {
return item.noUseRestrictions;
}
if (item.canuseResult) {
return item.canuseResult.reason;
}
return "";
}
//
const couponList = ref([]);
//
const goodsCouponSel = ref({
id: "",
});
//
const couponSel = ref({
id: "",
});
//
const limitTimeDiscount = reactive({ id: "" });
//
const quansSelArr = computed(() => {
return [couponSel.value, goodsCouponSel.value].filter((v) => v.id);
});
const querForm = ref({
searchValue: "",
shopId: "",
shopName: "",
statusActiveIndex: 0,
});
const list = reactive({
page: 1,
size: 10,
status: "nomore",
data: [],
noCanUseCoupons: [],
canUseCoupons: [],
});
//
function formatCoupon() {
let canUseGoodsCoupon = [];
let canUseDiscountCoupon = [];
let noUseGoodsCoupon = [];
let noUseDiscountCoupon = [];
const user = shopUserInfo.value;
let shopInfo = uni.getStorageSync("shopInfo") || {};
const goodsOrderPrice = option.orderPrice || 0;
const dinnerType = option.dinnerType || "dine-in";
let goodsArr = returnAllGoodsList();
const canDikouGoodsArr = yskUtils.couponUtils.returnCanDikouGoods(
goodsArr,
user,
shopInfo
);
for (let i = 0; i < couponList.value.length; i++) {
const coupon = couponList.value[i];
const selCoupon =
myQuan.types.sel != 1
? quansSelArr.value.filter((v) => v.type != 2)
: quansSelArr.value.filter((v) => v.type == 2);
const canuseResult = yskUtils.couponUtils.returnCouponCanUse({
canDikouGoodsArr,
coupon,
goodsOrderPrice,
user,
selCoupon: selCoupon,
shopInfo,
limitTimeDiscount: limitTimeDiscount,
});
const { canUse, reason } = canuseResult;
if (coupon.type == 2) {
if (canUse || goodsCouponSel.value.id == coupon.id) {
canUseGoodsCoupon.push(coupon);
} else {
noUseGoodsCoupon.push({
...coupon,
canuseResult,
});
}
} else {
if (canUse || couponSel.value.id == coupon.id) {
canUseDiscountCoupon.push(coupon);
} else {
noUseDiscountCoupon.push({
...coupon,
canuseResult,
});
}
}
}
//
canUseGoodsCoupon = canUseGoodsCoupon.map((v) => {
const discount = yskUtils.couponUtils.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
goodsOrderPrice,
quansSelArr.value.filter((v) => v.type != 2),
shopInfo,
limitTimeDiscount
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
//
canUseDiscountCoupon = canUseDiscountCoupon.map((v) => {
const discount = yskUtils.couponUtils.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
goodsOrderPrice,
quansSelArr.value.filter((v) => v.type == 2),
shopInfo,
limitTimeDiscount
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
if (myQuan.types.sel == 1) {
list.noCanUseCoupons = noUseGoodsCoupon;
list.canUseCoupons = canUseGoodsCoupon;
} else {
list.noCanUseCoupons = noUseDiscountCoupon;
list.canUseCoupons = canUseDiscountCoupon;
}
console.log("list", list);
console.log("canUseGoodsCoupon", canUseGoodsCoupon);
console.log("noUseGoodsCoupon", noUseGoodsCoupon);
console.log("canUseDiscountCoupon", canUseDiscountCoupon);
console.log("noUseDiscountCoupon", noUseDiscountCoupon);
} }
let user = reactive({
isVip: false
})
let $fullReductionCoupon = []
let $productCoupon = []
async function getQuan() { async function getQuan() {
order.value = await orderApi.tbOrderInfoDetail(option.orderId) const orderRes = await orderApi.tbOrderInfoDetail(option.orderId);
if (order.value.memberId) { if (orderRes.code == 200) {
const userRes = await queryAllShopUser({ order.value = orderRes.data;
id: order.value.memberId
})
if (userRes.content[0]) {
user.value = userRes.content[0]
}
} }
console.log(order.value); console.log(order.value);
const res = await $activateByOrderId({
orderId: option.orderId,
memberId: option.memberId
})
canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
res.fullReductionCoupon = res.fullReductionCoupon.map((v) => {
if(option.orderPrice<=0){
return {...v,use:false}
}else{
return{
...v,
use:v.use && option.orderPrice * 1 >= v
.fullAmount * 1
}
}
}) const res = await $findCoupon({
res.productCoupon = res.productCoupon.map(v => { shopUserId: option.shopUserId,
const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value) });
return { couponList.value = res.data || [];
...calcCoup, formatCoupon();
checked: false,
use:option.orderPrice<=0?false:v.use
}
}).filter((v) => v.use);
$fullReductionCoupon = res.fullReductionCoupon
$productCoupon = res.productCoupon
myQuan.res = res
myQuan.hasAjax = true; myQuan.hasAjax = true;
} }
const option = reactive({ const option = reactive({
orderId: '', orderId: "",
memberId: '', shopUserId: "",
orderPrice: 0 orderPrice: 0,
}) });
function toEmitChooseQuan(item) { function toEmitChooseQuan(item) {
let arr = [] let arr = [];
if (item) { if (item) {
arr = [item] arr = [item];
} else { } else {
if (myQuan.fullReductionCouponSel.id) { if (myQuan.fullReductionCouponSel.id) {
arr.push(myQuan.fullReductionCouponSel) arr.push(myQuan.fullReductionCouponSel);
} }
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked) const goodsQuan = myQuan.res.productCoupon.filter((v) => v.checked);
arr.push(...goodsQuan) arr.push(...goodsQuan);
} }
uni.$emit('choose-quan', arr) uni.$emit("choose-quan", arr);
back() back();
} }
const discountAmount = computed(() => { const discountAmount = computed(() => {
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked) return quansSelArr.value.reduce((pre, cur) => pre + cur.discountAmount, 0);
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : [] });
let coupArr = [...fullReductionCoupon, ...goodsQuan]
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
})
const payPrice = computed(() => { const payPrice = computed(() => {
const pay = option.orderPrice - discountAmount.value const pay = option.orderPrice - discountAmount.value;
return (pay < 0 ? 0 : pay).toFixed(2) return (pay < 0 ? 0 : pay).toFixed(2);
}) });
watch(() => myQuan.types.sel, (newval) => { watch(
if (newval == 0) { () => myQuan.types.sel,
myQuan.res.fullReductionCoupon = returnCanUseFullReductionCoupon($fullReductionCoupon, payPrice.value, (newval) => {
myQuan.fullReductionCouponSel) formatCoupon();
} }
if (newval == 1) { );
watch(
() => couponSel.value.id,
(newval) => {
formatCoupon();
}
);
watch(
() => goodsCouponSel.value.id,
(newval) => {
formatCoupon();
}
);
watch(
() => quansSelArr.value,
(newval) => {
const user = shopUserInfo.value;
let shopInfo = uni.getStorageSync("shopInfo") || {};
const goodsOrderPrice = option.orderPrice || 0;
const dinnerType = option.dinnerType || "dine-in";
let goodsArr = returnAllGoodsList();
const canDikouGoodsArr = yskUtils.couponUtils.returnCanDikouGoods(
goodsArr,
user,
shopInfo
);
console.log(canDikouGoodsArr);
let goodsCoupon = newval.filter((v) => v.type == 2);
let otherCoupon = newval.filter((v) => v.type != 2);
goodsCoupon = goodsCoupon.map((v) => {
const discount = yskUtils.couponUtils.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
goodsOrderPrice,
[],
shopInfo,
limitTimeDiscount
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
otherCoupon = otherCoupon.map((v) => {
const discount = yskUtils.couponUtils.returnCouponDiscount(
canDikouGoodsArr,
v,
user,
goodsOrderPrice,
goodsCoupon,
shopInfo,
limitTimeDiscount
);
return {
...v,
discount,
discountAmount: discount ? discount.discountPrice : v.discountAmount,
};
});
uni.$emit("selCoupon", [...goodsCoupon, ...otherCoupon]);
},
{
deep: true,
} }
}) );
onLoad((opt) => { async function getShopUser() {
Object.assign(option, opt) const res = await shopUserDetail({
getQuan() id: option.shopUserId,
}) });
let safebottomHeight = ref(0) if (res.code == 200) {
shopUserInfo.value = res.data;
}
}
onLoad(async (opt) => {
Object.assign(option, opt);
await getShopUser();
getQuan();
});
let safebottomHeight = ref(0);
onReady(() => { onReady(() => {
getSafeBottomHeight('bottom', 0).then(height => { getSafeBottomHeight("bottom", 0).then((height) => {
console.log(height); console.log(height);
safebottomHeight.value = height safebottomHeight.value = height;
}) });
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
// $quan-color:rgb(233, 77, 60); // $quan-color:rgb(233, 77, 60);
$quan-color: #318AFE; $quan-color: #318afe;
.no-use { .no-use {
position: absolute; position: absolute;
@ -445,7 +640,6 @@
height: 40rpx; height: 40rpx;
border-radius: 40rpx; border-radius: 40rpx;
opacity: 0; opacity: 0;
} }
.active { .active {
@ -459,7 +653,7 @@
position: relative; position: relative;
&::after { &::after {
content: ''; content: "";
position: absolute; position: absolute;
left: -30rpx; left: -30rpx;
display: block; display: block;
@ -483,7 +677,8 @@
height: 40rpx; height: 40rpx;
border-radius: 40rpx; border-radius: 40rpx;
&.active {} &.active {
}
} }
.use-btn { .use-btn {
@ -522,7 +717,11 @@
.hui { .hui {
// background-color: $quan-color; // background-color: $quan-color;
background-image: linear-gradient(to right bottom, rgb(254, 103, 4), rgb(241, 50, 42)); background-image: linear-gradient(
to right bottom,
rgb(254, 103, 4),
rgb(241, 50, 42)
);
padding: 4rpx 10rpx; padding: 4rpx 10rpx;
border-radius: 10rpx; border-radius: 10rpx;
font-size: 24rpx; font-size: 24rpx;

1307
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
import { defineConfig } from 'vite' import {
defineConfig
} from 'vite'
import uni from '@dcloudio/vite-plugin-uni' import uni from '@dcloudio/vite-plugin-uni'
export default defineConfig({ export default defineConfig({
@ -14,8 +16,8 @@ export default defineConfig({
}, },
"/ysk": { "/ysk": {
// 需要被代理的后台地址 // 需要被代理的后台地址
"target" : "http://192.168.1.42", target: "http://192.168.1.42",
"changeOrigin": true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/ysk/, '') rewrite: (path) => path.replace(/^\/ysk/, '')
}, },
} }

View File

@ -33,7 +33,7 @@ module.exports = {
rewrite: '/' // 重写路径 rewrite: '/' // 重写路径
}, },
"/ysk": { "/ysk": {
"target": "http://192.168.1.42", target: "http://192.168.1.42",
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
"^/ysk": "" "^/ysk": ""