Compare commits
68 Commits
16dac8d97f
...
develop
Author | SHA1 | Date | |
---|---|---|---|
8352b02110 | |||
2d3147d65d | |||
1c8de323fe | |||
b50eb2f1c2 | |||
894818401e | |||
596433ed86 | |||
e16e1e3bdc | |||
de509c7e14 | |||
13ee0f593c | |||
14b723ce1f | |||
41384ef8e9 | |||
f83bf3dd98 | |||
6921c82ad3 | |||
fe91157f6c | |||
63b30c0695 | |||
49b1968ba5 | |||
a620ecf624 | |||
4b4ee44242 | |||
613c0df738 | |||
8f06cf703d | |||
351e675c6d | |||
7bbf436a1c | |||
9d138814f2 | |||
f0ca5624ea | |||
947d85c1c6 | |||
183a95f48b | |||
c56ea0dd73 | |||
4d7f73aedf | |||
3945b36b0a | |||
4344adeb0b | |||
11a0637039 | |||
b53dc2dd4f | |||
0c0d5e55d5 | |||
b7461002dc | |||
68262d0519 | |||
d757f99b5d | |||
e910a76437 | |||
85d52f5065 | |||
915ff6b184 | |||
e92323a15b | |||
048ce5fd05 | |||
448ee810de | |||
6cd0361f33 | |||
0b1f0b9e26 | |||
531a955fe2 | |||
cb40ce643f | |||
f547216c2b | |||
62c9994444 | |||
100744cfaf | |||
74dba2ef29 | |||
dccdd43e3a | |||
eb1abb69fd | |||
68cce822be | |||
5bbfff9e21 | |||
7f6ace8ac6 | |||
bb9a32d296 | |||
bfc04c54aa | |||
5b8c7d4a2d | |||
634e801eb5 | |||
7b3676eda7 | |||
6c4c2ac85d | |||
b87c8e8292 | |||
32aa0eb971 | |||
178e8ff5cb | |||
0562554266 | |||
877469ab43 | |||
13fd77f13b | |||
f2f7fcde48 |
@@ -4,6 +4,8 @@ VITE_APP_TITLE='uniapp-vue3-project'
|
||||
# 开发环境配置
|
||||
VITE_APP_ENV='development'
|
||||
|
||||
VITE_APP_ID='wx92e663dc11d0c0a8'
|
||||
|
||||
# 接口地址
|
||||
VITE_APP_BASE_API='https://apidev.lakeapp.cn/'
|
||||
|
||||
|
@@ -4,8 +4,10 @@ VITE_APP_TITLE='uniapp-vue3-project'
|
||||
# 生产环境配置
|
||||
VITE_APP_ENV='production'
|
||||
|
||||
VITE_APP_ID='wx67a750d0ceed4d88'
|
||||
|
||||
# 接口地址
|
||||
VITE_APP_BASE_API='http://api.lakeapp.cn/'
|
||||
VITE_APP_BASE_API='https://api.lakeapp.cn/'
|
||||
|
||||
# 删除console
|
||||
VITE_DROP_CONSOLE=true
|
||||
|
14
.env.test
14
.env.test
@@ -1,11 +1,17 @@
|
||||
# 页面标题
|
||||
VITE_APP_TITLE='uniapp-vue3-project'
|
||||
|
||||
# 生产环境配置
|
||||
VITE_APP_ENV='production'
|
||||
# 开发环境配置
|
||||
VITE_APP_ENV='test'
|
||||
|
||||
VITE_APP_ID='wx92e663dc11d0c0a8'
|
||||
|
||||
# 接口地址
|
||||
VITE_APP_BASE_API='/'
|
||||
#VITE_APP_BASE_API='https://apidev.lakeapp.cn/'
|
||||
VITE_APP_BASE_API='https://api.lakeapp.cn/'
|
||||
|
||||
# 删除console
|
||||
VITE_DROP_CONSOLE=true
|
||||
VITE_DROP_CONSOLE=false
|
||||
|
||||
# 是否开启Mock
|
||||
VITE_USE_MOCK=true
|
||||
|
@@ -14,7 +14,7 @@ const WX_DESC = envType == 'production' ? '正式环境' : '测试环境'
|
||||
(async () => {
|
||||
// @ts-ignore
|
||||
const manifest = path.resolve(__dirname, './src/manifest.json')
|
||||
console.log(manifest)
|
||||
|
||||
// @ts-ignore
|
||||
const manifestConfig = JSON.parse(fs.readFileSync(manifest).toString())
|
||||
const appId = manifestConfig['mp-weixin'].appid
|
||||
|
27
keys/private.wx67a750d0ceed4d88.key
Normal file
27
keys/private.wx67a750d0ceed4d88.key
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAw7dY+KsQ9Qa1Q0Amp2bNWW3/ch/2OmS5SsiXSfRgVLKcUB1C
|
||||
1svyjDUzqaw53Rhn4WdwUCFQCkhWs1ud7NA/eudaqLmvrX0SaH6bJz2XCzyNoElM
|
||||
amHh0U4sKEFcOcY9FPsriislpCmKnOKjyKB6fnpzIn7JxespswhiDsiKC2dk/8nB
|
||||
GFeN559MYy6qOUyFrykkcF21oSfOynhw+ziqxRBIKh30dR1nUy+FZrZiVx2Bj/id
|
||||
39AbZ89lK8pzdlFHtXqd56UCe5fEselh+KbT4eKIEhHoO+vSqralASLDMxijgA3V
|
||||
49AUmpQ6F4nW9GfF3/IreX8X7k457M6FKo8L1QIDAQABAoIBABnTb+IgcLRkljax
|
||||
mGguoJpUcYjVvuAlum2r2orfvHZwuz+3HMLLVs45lv+kwl3ygoKz65YnTzCMKySv
|
||||
yj8dm8LUFJp/Jjd2cZ9oVYDwF6Zb7zRfd73x/KJp9lm5hjn5dsX1/uDUoLrw4GGj
|
||||
Zolq478c2WSL5oQ/a9k8GfRpcg3e88L89r6QjZuQ3jmVxe4fJlYbUR3YXE2t3c41
|
||||
v/uQfxXvvVrYGc8/jZE4AQcFbZhKu1xfl7dy8AEisZa4OxU5Gd+onHcnUgGO6oRn
|
||||
x0pZQnZJZoTLJe8uB0jl+OPLLQbRcA01jITKAHKOqOQYgynfzy6xfMWhNk/4YWtf
|
||||
oJ+wFmECgYEA7H/Iov01m7+k+oe3XyiQC0zMLtHWzF3thdAUJFRZPBfzb5X/F9a2
|
||||
k+feK69aXHnsWtVKO1kZ+FMMs7OU0LOX+LRDeeiJqlhnuOC63NfyZ6yfgOEBq38s
|
||||
C7rxgsuS6D5VvEzj57sjBGRTyfjNZVvfflBMVn9JgwVzdo9RumLnD98CgYEA09qv
|
||||
IJtFlPcAbIuKQMRUnrLVDI5hMYzQUwpj4RkBOASIgCtJHUoN4GvdAaYeE6q9eeD1
|
||||
TyKyIJekECejOqLdzidE/aOVRWcgiEjxjGf4e9n4/6q9CJGH7v2WMNbziALHb6We
|
||||
KBwrIdaakD7m2yVZ1PxTyljCXx3wvv3IN/khSssCgYEAv8CH2+cz3RlQ2bTKcARC
|
||||
bncRInEPGNqbaCCjBCXDyF6fCX1zvE9h76BTWdYujMZqZeeD7YS78sTbiqRzZ5gG
|
||||
Ayedgi2R2SUezB6iQ8dvirHDDcriALv26Xfks6j9bwKDn040h0ILDVePPDZXyvPn
|
||||
zNGsY4GHCA2WZa2klVv1fr8CgYBCkMPWCvOiCronYPDfyNCNzMMEXvhLCWOrs+gO
|
||||
Ij0vzLzXCMLAYTRa/4lBq2Bn7Y37baOmadBuTTdPnCS9l875p30V9QBB/lVKfSDo
|
||||
bQK2Z5bFPnCG8LM1dJhsYB3E7pqbif5XvAIRb8zA5gLDeMjxExeAzMLGADJU0IjI
|
||||
jY7YYQKBgFy7WTwnEV4NTjus1FXj4Bf1BYJRrDRtxMNiKWZZ+C1XQqA1zWiIfDzt
|
||||
B1LKjBwWZsM2ali582PcMkJYPVZBG+hMmHlAme/acpzGF4oiANZp+kCcrnxFvKvs
|
||||
PAO6ui1zDN92bGNf/LQQOf1TM29sUbAFnwxNFOxvs2FbpWvFj0V3
|
||||
-----END RSA PRIVATE KEY-----
|
@@ -1,27 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAtAuySwDuVUqiKAgtB8yhmDXMbFtgSZQiC4FtahrqAxcwcett
|
||||
khfncnldZZGMUtK3dM/xA5YaKe18vish3qbymwc+863r2NKIFtWhWIglXDuutGgT
|
||||
U9/IqCnh4Dx8Owlw5/EzbvHSXj1/uzwuAVO6cxkkEvz9mxYixuB3YCd8yKQ5rLnu
|
||||
EwNf063fI+jDVUBeyEejSZJ0pi3OzWdXJOjS9UYv2bAYOfJluGucfDXMbfdz8euy
|
||||
T8WRCPJp4X2QoQU5WcSxWnvRSllwAfposZTIcu/msXm77QwoYqCHvJ2suGzL+SXa
|
||||
c73wQB289dXqHbYmSa7bPmTmOEyCPYao0oIh8wIDAQABAoIBACfpb9ywmCTQJqI5
|
||||
LcJM2oWjZ22d0/p7nBBw4JBk5vtIaLTYO7HnGqeFv+6EFVdG3uRGNGdXHvWsb7q4
|
||||
VQnGeIFlWc8q/t1RzllBgkLd62pG0LOtXpt5QEIHBstunRt5PE4uafhuIvRBLc+T
|
||||
x58DsJFTQWv0KUP35D2yBMSL/F19qqF6oe43kYbAei8w608XXKOT/rODdk1Ie3yx
|
||||
AOgM4DvTqcSdqL/SDJ6r8xoplDNk4l+QYCJ9z7JodnJfU5OQVWw8WFWRg3jP9k/S
|
||||
DsojcusTs1s14X8V3/TbR1vVW6g4Q5QnNFozHaKRZAD9DuBStrL02hgAq7oXdg+g
|
||||
IoMR+AECgYEA7VVuOWwt2aWXks9aPpOVs9knMdrpxbO1nE/B2JECICElFtL8xwUi
|
||||
BxWcM++wJNtKTAjJfpnFGZkyHfmnB8V0itGIz1lCZTs/yraJqaLxQdbHjEnCoCRq
|
||||
tl1751hsBS15XFDskKHGFZj0wv9nq3I0wUoMjhsRV+Lopq+uHCodcgMCgYEAwjTO
|
||||
dwh/0cTjiGOV8iX9WdM0I3wnYfcAgDbxGKNyZNw8oQ52vzTn1VG+LcxMcy+OUq/a
|
||||
B/XBjkUI4WyHfK7zM6rhlQB8pWR3i+yPyLXJ69oRQwYAeHQzgZ6Z+sSsusHcG/wN
|
||||
J/Z9EqiWQK/tZsBXQxDpHqxwz9Xl1BlL0xX9BVECgYBHKsr2pR3KmgEtoMfq486M
|
||||
M52xMXfQNOdMjA4QpssAX3ADvBjYhQ2DGlPQrxsesjNBQZFKSUn1Nx70JhyUE/2y
|
||||
csqXgqiKOo4Sd1IocBfwKjuEMcoOw1zMepPg937MvqoZqJqHdDs11rvujS/FFWYE
|
||||
X/QL2MoGlKA2+482GtrhiQKBgQCTt8jnn45hx2nuXxk5w42umkiJSTFHgbJe0+uU
|
||||
+xXTA/YV50OJcrt4daG7gi8QWjbeTCYCcfrUtUvo8z0nKIeSYEMPq/wjbYTE6J4B
|
||||
Y8z/2bHRkiofdPuMd0/V/20G7Nf4bUKwh/tgit0mvOpNgrWdLKq1CyMP4znal5cm
|
||||
Kw520QKBgB+I8yfp/E01ruSccdgRH3WMGStuHhSxcQ8WWD9oFdOn+klxr8h4al3+
|
||||
Ibo6SJkKmwg2/IEsuc52qZPH5594XfQ7HxfVf9RVwdR96epRqah/cHofIVCX1wQB
|
||||
CCirZNNiBe2hQxDyAHn492a6dzcjMojDN5JS+Yt071CB0Tph7+2c
|
||||
-----END RSA PRIVATE KEY-----
|
40
manifest.modify.ts
Normal file
40
manifest.modify.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// @ts-ignore
|
||||
const fs = require('fs');
|
||||
// @ts-ignore
|
||||
const path = require('path');
|
||||
|
||||
const currentDir = path.dirname(__filename);
|
||||
const manifestPath = path.join(currentDir, 'src/manifest.json');
|
||||
|
||||
const VITE_APP_WX_APPID = process.env.NODE_ENV === 'production' ? 'wx67a750d0ceed4d88' : 'wx92e663dc11d0c0a8';
|
||||
fs.readFile(manifestPath, (err, data) => {
|
||||
if(err) {
|
||||
console.error(err);
|
||||
} else {
|
||||
try {
|
||||
if(!VITE_APP_WX_APPID) {
|
||||
console.log('写入失败,没读到appid');
|
||||
return;
|
||||
}
|
||||
const _data = JSON.parse(data.toString());
|
||||
_data['mp-weixin'].appid = VITE_APP_WX_APPID;
|
||||
const newData = JSON.stringify(_data, null, 2);
|
||||
fs.writeFile(
|
||||
manifestPath,
|
||||
newData,
|
||||
{
|
||||
encoding: 'utf-8'
|
||||
},
|
||||
(err) => {
|
||||
if(err) {
|
||||
console.log('APPID 写入失败', err);
|
||||
} else {
|
||||
console.log(`APPID 写入成功 ${VITE_APP_WX_APPID}`);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (parseError) {
|
||||
console.error('解析 manifest.json 失败', parseError);
|
||||
}
|
||||
}
|
||||
});
|
58
package.json
58
package.json
@@ -4,10 +4,12 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "uni -p mp-weixin",
|
||||
"build:test": "uni build --mode test -p mp-weixin",
|
||||
"build:prod": "uni build --mode production -p mp-weixin",
|
||||
"deploy:test": "uni build --mode test -p mp-weixin && node deploy.ts test",
|
||||
"deploy:prod": "uni build --mode production -p mp-weixin && node deploy.ts production",
|
||||
"dev:test": "cross-env NODE_ENV=development node manifest.modify.ts && uni -p mp-weixin --mode development",
|
||||
"dev:prod": "cross-env NODE_ENV=production node manifest.modify.ts && uni -p mp-weixin --mode production",
|
||||
"build:test": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build --mode test",
|
||||
"build:prod": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build --mode production",
|
||||
"deploy:test": "cross-env NODE_ENV=test node manifest.modify.ts && uni build --mode test -p mp-weixin && node deploy.ts test",
|
||||
"deploy:prod": "cross-env NODE_ENV=production node manifest.modify.ts && uni build --mode production -p mp-weixin && node deploy.ts production",
|
||||
"type-check": "vue-tsc --noEmit",
|
||||
"eslint": "eslint --fix",
|
||||
"stylelint": "stylelint \"src/**/*.(vue|scss|css)\" --fix",
|
||||
@@ -15,53 +17,53 @@
|
||||
"postinstall": "simple-git-hooks"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dcloudio/uni-app": "3.0.0-4000820240401001",
|
||||
"@dcloudio/uni-app-plus": "3.0.0-4000820240401001",
|
||||
"@dcloudio/uni-components": "3.0.0-4000820240401001",
|
||||
"@dcloudio/uni-mp-weixin": "3.0.0-4000820240401001",
|
||||
"@dcloudio/uni-app": "3.0.0-alpha-4010520240507001",
|
||||
"@dcloudio/uni-app-plus": "3.0.0-alpha-4010520240507001",
|
||||
"@dcloudio/uni-components": "3.0.0-alpha-4010520240507001",
|
||||
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-4010520240507001",
|
||||
"dayjs": "^1.11.10",
|
||||
"pinia": "2.0.36",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"uview-plus": "^3.1.38",
|
||||
"uview-plus": "^3.1.41",
|
||||
"vue": "3.4.21",
|
||||
"vue-i18n": "^9.9.0",
|
||||
"z-paging": "^2.6.2"
|
||||
"z-paging": "^2.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "1.1.0",
|
||||
"@dcloudio/types": "^3.4.3",
|
||||
"@dcloudio/uni-automator": "3.0.0-4000820240401001",
|
||||
"@dcloudio/uni-cli-shared": "3.0.0-4000820240401001",
|
||||
"@dcloudio/uni-stacktracey": "3.0.0-4000820240401001",
|
||||
"@dcloudio/vite-plugin-uni": "3.0.0-4000820240401001",
|
||||
"@types/node": "^20.8.10",
|
||||
"@typescript-eslint/parser": "^6.10.0",
|
||||
"@uni-helper/uni-app-types": "^0.5.9",
|
||||
"@unocss/eslint-plugin": "^0.57.2",
|
||||
"@dcloudio/types": "^3.4.8",
|
||||
"@dcloudio/uni-automator": "3.0.0-alpha-4010520240507001",
|
||||
"@dcloudio/uni-cli-shared": "3.0.0-alpha-4010520240507001",
|
||||
"@dcloudio/uni-stacktracey": "3.0.0-alpha-4010520240507001",
|
||||
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-4010520240507001",
|
||||
"@types/node": "^20.10.3",
|
||||
"@typescript-eslint/parser": "^6.13.1",
|
||||
"@uni-helper/uni-app-types": "^0.5.12",
|
||||
"@unocss/eslint-plugin": "^0.57.7",
|
||||
"@vue/runtime-core": "^3.4.21",
|
||||
"@vue/tsconfig": "^0.4.0",
|
||||
"czg": "^1.7.1",
|
||||
"eslint": "^8.53.0",
|
||||
"lint-staged": "^15.0.2",
|
||||
"miniprogram-ci": "^1.9.8",
|
||||
"eslint": "^8.55.0",
|
||||
"lint-staged": "^15.2.0",
|
||||
"miniprogram-ci": "^1.9.10",
|
||||
"picocolors": "^1.0.0",
|
||||
"postcss-html": "^1.5.0",
|
||||
"postcss-scss": "^4.0.9",
|
||||
"sass": "^1.69.5",
|
||||
"simple-git-hooks": "^2.9.0",
|
||||
"stylelint": "^15.11.0",
|
||||
"stylelint-config-recess-order": "^4.3.0",
|
||||
"stylelint-config-recess-order": "^4.4.0",
|
||||
"stylelint-config-standard": "^34.0.0",
|
||||
"stylelint-config-standard-vue": "^1.0.0",
|
||||
"stylelint-order": "^6.0.3",
|
||||
"typescript": "^5.2.2",
|
||||
"unocss": "^0.57.2",
|
||||
"unocss-applet": "^0.7.7",
|
||||
"typescript": "^5.3.2",
|
||||
"unocss": "^0.57.7",
|
||||
"unocss-applet": "^0.7.8",
|
||||
"unplugin-auto-import": "^0.16.7",
|
||||
"unplugin-vue-components": "^0.25.2",
|
||||
"vite": "^4.5.2",
|
||||
"vite": "^5.2.8",
|
||||
"vite-plugin-imagemin": "^0.6.1",
|
||||
"vue-tsc": "^1.8.22"
|
||||
"vue-tsc": "^1.8.24"
|
||||
},
|
||||
"lint-staged": {
|
||||
"src/**/*.{js,jsx,ts,tsx}": "eslint --fix",
|
||||
|
2799
pnpm-lock.yaml
generated
2799
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
240
src/App.vue
240
src/App.vue
@@ -1,18 +1,230 @@
|
||||
<script setup lang='ts'>
|
||||
import { mpUpdate } from '@/utils';
|
||||
<script lang='ts'>
|
||||
import {
|
||||
getCompanyId,
|
||||
getQueryParam,
|
||||
getRegisterStoreId,
|
||||
mpUpdate,
|
||||
setCompanyId,
|
||||
setReferrerUserId,
|
||||
setRegisterStoreId
|
||||
} from '@/utils';
|
||||
import { Logger } from '@/utils/common/logger';
|
||||
|
||||
const logger = new Logger();
|
||||
|
||||
export default {
|
||||
onLaunch: async (options: any) => {
|
||||
const miniProgram = uni.getAccountInfoSync().miniProgram;
|
||||
const env = miniProgram.envVersion;
|
||||
|
||||
console.log(`App Launch options ${env}: `, options);
|
||||
|
||||
//生产
|
||||
if(env === 'release') {
|
||||
logger.info(`App Launch options ${env}: `, options);
|
||||
|
||||
async function getVersionStatus() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: 'https://api.lakeapp.cn/wechat/version_info',
|
||||
success(res) {
|
||||
console.log(res);
|
||||
resolve(res);
|
||||
},
|
||||
fail(exception) {
|
||||
reject(exception);
|
||||
}
|
||||
});
|
||||
}).then((res) => {
|
||||
const { version, audit } = res.data;
|
||||
// if(miniProgram.version === version && audit == 1) {
|
||||
if(audit == 1) {
|
||||
setCompanyId('1150930317231112193');
|
||||
setRegisterStoreId('1150930317436633090');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await getVersionStatus();
|
||||
}
|
||||
|
||||
//测试、开发 trial,develop
|
||||
else {
|
||||
//生产环境
|
||||
if(import.meta.env.VITE_APP_BASE_API.includes('api.lakeapp')) {
|
||||
setCompanyId('1150930317231112193');
|
||||
setRegisterStoreId('1150930317436633090');
|
||||
|
||||
// setCompanyId('1471673498334113794');
|
||||
// setRegisterStoreId('1471673498413805570');
|
||||
}
|
||||
//测试
|
||||
else {
|
||||
setCompanyId('1724629180555919361');
|
||||
setRegisterStoreId('1725026299888406529');
|
||||
// setRegisterStoreId('17250262998884000000');
|
||||
}
|
||||
}
|
||||
|
||||
if(options?.query) {
|
||||
|
||||
// options.query.scene = 'companyId%3D1150930317231112193%26wxOpenId%3D111%26ticketId%3D123456%26storeId%3D1150930317436633090'
|
||||
|
||||
//保存登录邀请员工id
|
||||
if(options.query.referrerUserId) {
|
||||
setReferrerUserId(options.query.referrerUserId);
|
||||
}
|
||||
|
||||
//保存注册门店id
|
||||
if(options.query.companyId) {
|
||||
setCompanyId(options.query.companyId);
|
||||
}
|
||||
|
||||
//保存注册门店id
|
||||
if(options.query.storeId) {
|
||||
setRegisterStoreId(options.query.storeId);
|
||||
}
|
||||
|
||||
if(options?.query.scene) {
|
||||
//保存注册门店id
|
||||
const params = decodeURIComponent(options?.query.scene);
|
||||
if(params.includes('companyId')) {
|
||||
setCompanyId(getQueryParam(params, 'companyId') || '');
|
||||
}
|
||||
if(params.includes('storeId')) {
|
||||
setRegisterStoreId(getQueryParam(params, 'storeId') || '');
|
||||
}
|
||||
if(options?.query.scene === 'edit_avatar_nickname') {
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/mine/subs/profile/index'
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`App Launch options ${env}: { companyId: `, getCompanyId() + ', storeId: ' + getRegisterStoreId() + ' }');
|
||||
|
||||
// #ifdef MP
|
||||
mpUpdate();
|
||||
// #endif
|
||||
},
|
||||
onShow: async () => {
|
||||
console.log('App Show');
|
||||
},
|
||||
onHide: async () => {
|
||||
console.log('App Hide');
|
||||
},
|
||||
|
||||
globalData: {
|
||||
logger: logger,
|
||||
companyId: getCompanyId(),
|
||||
storeId: getRegisterStoreId(),
|
||||
shareCompanyId: '',//分享过来的公司id
|
||||
shareStoreId: '',//分享过来的店铺id
|
||||
sharePath: ''//分享页面路径,方便登录后跳转
|
||||
}
|
||||
};
|
||||
|
||||
// onLaunch(async (options) => {
|
||||
// console.log('App Launch options ', options);
|
||||
// // globalData.logger.info('launch options : ', options);
|
||||
//
|
||||
// const miniProgram = uni.getAccountInfoSync().miniProgram;
|
||||
// const env = miniProgram.envVersion;
|
||||
//
|
||||
// logger.info('launch options env : ', `${env} ${options}`);
|
||||
// //生产
|
||||
// if(env === 'release' || env === 'trial') {
|
||||
// async function getVersionStatus() {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// uni.request({
|
||||
// url: 'https://api.lakeapp.cn/wechat/version_info',
|
||||
// success(res) {
|
||||
// console.log(res);
|
||||
// resolve(res);
|
||||
// },
|
||||
// fail(exception) {
|
||||
// reject(exception);
|
||||
// }
|
||||
// });
|
||||
// }).then((res) => {
|
||||
// const { version, audit } = res.data;
|
||||
// // if(miniProgram.version === version && audit == 1) {
|
||||
// if(audit == 1) {
|
||||
// setCompanyId('1150930317231112193');
|
||||
// setRegisterStoreId('1150930317436633090');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// await getVersionStatus();
|
||||
// }
|
||||
//
|
||||
// //测试、开发 trial,develop
|
||||
// else {
|
||||
// // setCompanyId('1724629180555919361');
|
||||
// // setRegisterStoreId('1725026299888406529');
|
||||
// setCompanyId('1471673498334113794');
|
||||
// setRegisterStoreId('1471673498413805570');
|
||||
// }
|
||||
//
|
||||
// if(options?.query) {
|
||||
//
|
||||
// // options.query.scene = 'companyId%3D1150930317231112193%26wxOpenId%3D111%26ticketId%3D123456%26storeId%3D1150930317436633090'
|
||||
//
|
||||
// //保存登录邀请员工id
|
||||
// if(options.query.referrerUserId) {
|
||||
// setReferrerUserId(options.query.referrerUserId);
|
||||
// }
|
||||
//
|
||||
// //保存注册门店id
|
||||
// if(options.query.companyId) {
|
||||
// setCompanyId(options.query.companyId);
|
||||
// }
|
||||
//
|
||||
// //保存注册门店id
|
||||
// if(options.query.storeId) {
|
||||
// setRegisterStoreId(options.query.storeId);
|
||||
// }
|
||||
//
|
||||
// if(options?.query.scene) {
|
||||
// function getQueryParam(queryParams: string, key: string) {
|
||||
// let regex = new RegExp('(?:[?&]|^)' + key + '=([^&]+)'),
|
||||
// match = queryParams.match(regex);
|
||||
// return match && match[1];
|
||||
// }
|
||||
//
|
||||
// //保存注册门店id
|
||||
// const params = decodeURIComponent(options?.query.scene);
|
||||
// if(params.includes('companyId')) {
|
||||
// setCompanyId(getQueryParam(params, 'companyId') || '');
|
||||
// }
|
||||
// if(params.includes('storeId')) {
|
||||
// setRegisterStoreId(getQueryParam(params, 'storeId') || '');
|
||||
// }
|
||||
// if(options?.query.scene === 'edit_avatar_nickname') {
|
||||
// setTimeout(() => {
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/mine/subs/profile/index'
|
||||
// });
|
||||
// }, 500);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // #ifdef MP
|
||||
// mpUpdate();
|
||||
// // #endif
|
||||
// });
|
||||
// onShow(() => {
|
||||
// console.log('App Show');
|
||||
// });
|
||||
// onHide(() => {
|
||||
// console.log('App Hide');
|
||||
// });
|
||||
|
||||
onLaunch((options) => {
|
||||
console.log('App Launch options ', options);
|
||||
// #ifdef MP
|
||||
mpUpdate();
|
||||
// #endif
|
||||
});
|
||||
onShow(() => {
|
||||
console.log('App Show');
|
||||
});
|
||||
onHide(() => {
|
||||
console.log('App Hide');
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
|
@@ -2,3 +2,5 @@ import { get } from '@/utils/request';
|
||||
|
||||
export const getCompanyList = (maOpenId: string) => get({ url: `/wc/wechat/company?maOpenId=${maOpenId}` });
|
||||
export const getCompanyInfo = () => get({ url: `/ext/zconfig/company_find` });
|
||||
|
||||
export const getStoreId = (data: any) => get({ url: '/wc/wechat/get_store_id', data });
|
||||
|
@@ -26,6 +26,7 @@ export interface GoodsBean {
|
||||
name: string;
|
||||
price: number;
|
||||
send_num: number;
|
||||
priceExt: number;
|
||||
price_ext: number;
|
||||
payPrice: number;
|
||||
profile: string;
|
||||
|
@@ -6,20 +6,28 @@ export const getGroupBuyList = (data: {
|
||||
pageNum: number,
|
||||
pageSize: number,
|
||||
obj: {
|
||||
status: number,
|
||||
timeStatus: number,
|
||||
}
|
||||
}) => post({ url: '/group/coupons/wx_query', data });
|
||||
|
||||
export const getGroupBuyDetail = (
|
||||
id: string) => get<GroupBuyBean>({ url: `wechat/coupons/group/get/${id}` });
|
||||
|
||||
export const getShareGoodsDetail = (shareId: string) => post<any>({ url: '/wechat/coupons/group/qrcode/' + `${shareId}` });
|
||||
|
||||
export const getShareGoodsCouponDetail = (couponId: string) => get<GroupBuyBean>({ url: 'wechat/coupons/get/' + `${couponId}` });
|
||||
|
||||
export const getGroupBuyRecordList = (groupId: string, pageNum: number, pageSize: number) => post<RecordBean[]>({
|
||||
url: `wechat/coupons/group/order/list?groupId=${groupId}&pageNum=${pageNum}&pageSize=${pageSize}`
|
||||
});
|
||||
|
||||
export const preOrder = (data: any) => post<GoodsBean>({ url: 'wechat/coupons/group/pre_v2', data });
|
||||
export const preOrder = (data: any) => post<GoodsBean>({ url: 'wechat/coupons/pre', data });
|
||||
|
||||
export const preOrderV2 = (data: any) => post<GoodsBean>({ url: 'wechat/coupons/group/pre_v2', data });
|
||||
|
||||
export const progress = (data: any) => post<any>({ url: 'wechat/coupons/group/pay/progress', data });
|
||||
|
||||
export const pay = (data: any) => post<any>({ url: 'wechat/coupons/group/pay', data });
|
||||
|
||||
export const couponPay = (data: any) => post<any>({ url: 'wechat/coupons/pay', data });
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 用户信息相关接口
|
||||
*/
|
||||
import type { CouponBean, LoginParams, LoginResult, RegisterParams, TerminalBean } from './types';
|
||||
import type { CouponBean, LoginParams, LoginResult, RegisterParams, TerminalBean, SetPayPasswordParams,PayPasswordResponse} from './types';
|
||||
import { get, post } from '@/utils/request';
|
||||
import { UserBean } from '@/store/modules/user/types';
|
||||
|
||||
@@ -10,6 +10,7 @@ enum URL {
|
||||
login = '/wc/wechat/LoginByMa',
|
||||
loginByCode = '/wc/wechat/LoginByMaCode',
|
||||
register = '/wc/wechat/register',
|
||||
telephone = '/wc/wechat/telephone',
|
||||
uploadAvatar = '/wc/wechat/uploadImage',
|
||||
logout = '/user/logout',
|
||||
// profile = '/user/profile',
|
||||
@@ -30,7 +31,10 @@ enum URL {
|
||||
couponList = '/wechat/coupons/coupons/pageList',
|
||||
integralList = '/ext/member/integral_query',
|
||||
tradeList = '/memberIncoming/wx_balance_records',
|
||||
terminal = 'wechat/coupons/terminal?companyId='
|
||||
terminal = 'wechat/coupons/terminal?companyId=',
|
||||
cardLink = '/wc/wechat/get_card_url',
|
||||
registerCoupon = '/couponsStrategy/wx_register_coupon',
|
||||
setPayPassword = '/app/pay/set_paypwd',
|
||||
}
|
||||
|
||||
export const getUserProfile = () => get<UserBean>({ url: URL.profile });
|
||||
@@ -40,6 +44,8 @@ export const updateProfile = (data: any) => post<any>({ url: URL.updateProfile,
|
||||
export const login = (data: LoginParams) => post<LoginResult>({ url: URL.login, data });
|
||||
export const loginByCode = (code: string, companyId: string) => post<any>({ url: URL.loginByCode + `?code=${code}` });
|
||||
|
||||
export const getTelephone = (data: any) => post<any>({ url: URL.telephone, data });
|
||||
|
||||
export const register = (data: RegisterParams) => post<LoginResult>({ url: URL.register, data });
|
||||
|
||||
export const logout = () => post<any>({ url: URL.logout });
|
||||
@@ -49,7 +55,7 @@ export const getAddressDetail = (id: string) => get<any>({ url: URL.addressDetai
|
||||
|
||||
export const addressCreate = (data: any) => post<any>({ url: URL.addressCreate, data });
|
||||
export const addressUpdate = (data: any) => post<any>({ url: URL.addressUpdate, data });
|
||||
export const addressDelete = (id: string) => post<any>({ url: URL.addressDelete + `?id=${id}` });
|
||||
export const addressDelete = (id: string) => post<any>({ url: URL.addressDelete + `?addrid=${id}` });
|
||||
|
||||
export const getDynamicCode = () => post<any>({ url: URL.dynamicCode });
|
||||
|
||||
@@ -67,3 +73,15 @@ export const getIntegralList = (data: any) => get({ url: URL.integralList, data
|
||||
export const getTerminal = (companyId: string) => get<TerminalBean>({ url: URL.terminal + companyId });
|
||||
|
||||
export const getTradeList = (data: any) => post<any>({ url: URL.tradeList, data });
|
||||
|
||||
export const getCardLink = () => get<string>({ url: URL.cardLink });
|
||||
|
||||
export const getRegisterCoupon = () => get<any>({ url: URL.registerCoupon });
|
||||
|
||||
/**
|
||||
* 设置支付密码
|
||||
*/
|
||||
export const setPayPassword = (data: SetPayPasswordParams) => post<PayPasswordResponse>({
|
||||
url: URL.setPayPassword,
|
||||
data
|
||||
});
|
||||
|
@@ -4,7 +4,8 @@ export interface LoginParams {
|
||||
// phone: string;
|
||||
code: string;
|
||||
userInfo: any;
|
||||
referrerUserId: string;
|
||||
storeId: string;
|
||||
// referrerUserId: string;
|
||||
}
|
||||
|
||||
export interface RegisterParams {
|
||||
@@ -30,6 +31,7 @@ export interface LoginResult {
|
||||
user: UserBean;
|
||||
userInfo: any;
|
||||
token: string;
|
||||
maOpenId: string;
|
||||
}
|
||||
|
||||
export interface IntegralBean {
|
||||
@@ -116,3 +118,15 @@ export interface TerminalBean {
|
||||
token: string;
|
||||
type: number;
|
||||
}
|
||||
|
||||
export interface SetPayPasswordParams {
|
||||
paywithpwd: number // 0: 开启支付密码, 1: 关闭支付密码
|
||||
oldpwd: string,
|
||||
newpwd: string
|
||||
}
|
||||
|
||||
export interface PayPasswordResponse {
|
||||
success: boolean
|
||||
message: string
|
||||
hasPassword?: boolean
|
||||
}
|
||||
|
109
src/components/company-dialog.vue
Normal file
109
src/components/company-dialog.vue
Normal file
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<uni-popup ref='popupRef' type='bottom' :mask-click='false' @touchmove.stop.prevent=''>
|
||||
<view class='content'>
|
||||
<text class='title'>切换门店</text>
|
||||
<scroll-view scroll-y style='max-height: 600rpx;padding: 15rpx'>
|
||||
<view class='store-item' v-for='(item, index) in companyList' :key='index' @click='() => {
|
||||
handleClick(index)
|
||||
}'>
|
||||
<view class='c-flex-row'>
|
||||
<text>{{ item?.companyName || '' }}</text>
|
||||
<image v-if='index===currentIndex' src='/static/images/ic_checkmark_red.png' />
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class='close-btn primary-button' @click='close'>
|
||||
<text>取消</text>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
const props = defineProps({
|
||||
companyList: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
});
|
||||
|
||||
const popupRef = ref();
|
||||
const currentIndex = ref(0);
|
||||
let callback: Function;
|
||||
|
||||
const show = (companyId: string, fn: Function) => {
|
||||
if(companyId) {
|
||||
currentIndex.value = props.companyList.findIndex(item => item.id === companyId);
|
||||
}
|
||||
callback = fn;
|
||||
popupRef.value.open();
|
||||
};
|
||||
|
||||
const handleClick = (index: number) => {
|
||||
currentIndex.value = index;
|
||||
callback(index);
|
||||
close();
|
||||
};
|
||||
|
||||
const close = () => {
|
||||
popupRef.value.close();
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
show, close
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #FFFFFF;
|
||||
border-radius: 20rpx 20rpx 0 0;
|
||||
padding: 20rpx 30rpx 30rpx 30rpx;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
align-self: center;
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.store-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 35rpx;
|
||||
color: #333333;
|
||||
//padding: 20rpx 20rpx;
|
||||
|
||||
|
||||
.c-flex-row {
|
||||
text {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.store-item:after {
|
||||
content: '';
|
||||
background: #F5F5F5;
|
||||
height: 0.5rpx;
|
||||
width: 100%;
|
||||
margin: 25rpx 0;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: #F5F5F5;
|
||||
color: #333333;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
</style>
|
290
src/components/pay-password-dialog.vue
Normal file
290
src/components/pay-password-dialog.vue
Normal file
@@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<uni-popup ref="popup" type="center" :safe-area="true" :mask-click="false">
|
||||
<view class="pay-password-dialog">
|
||||
<view class="dialog-header">
|
||||
<text class="title">{{ getDialogTitle }}</text>
|
||||
<u-icon name="close" size="20" color="#999" @click="hide" />
|
||||
</view>
|
||||
|
||||
<view class="form-container">
|
||||
<!-- 关闭支付密码选项 -->
|
||||
<view class="switch-item" v-if="hasOldPassword">
|
||||
<text>关闭支付密码</text>
|
||||
<u-switch v-model="isClosePassword" activeColor="#F32B2B" @change="handleSwitchChange" />
|
||||
</view>
|
||||
|
||||
<!-- 旧密码 - 只在修改密码或关闭密码时显示 -->
|
||||
<view class="form-item" v-if="hasOldPassword">
|
||||
<text class="label">原密码:</text>
|
||||
<view class="input-wrapper">
|
||||
<u-input v-model="oldPassword" type="number" :border="false" placeholder="请输入原密码" :maxlength="6"
|
||||
:disabled="isClosePassword" :password="!showOldPassword" @input="handleInput($event, 'oldPassword')" />
|
||||
<u-icon :name="showOldPassword ? 'eye-off' : 'eye-fill'" size="20" color="#999"
|
||||
v-if="hasOldPassword && !isClosePassword" @click="showOldPassword = !showOldPassword" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 新密码和确认密码部分 -->
|
||||
<template v-if="!isClosePassword">
|
||||
<!-- 新密码 -->
|
||||
<view class="form-item">
|
||||
<text class="label">新密码:</text>
|
||||
<view class="input-wrapper">
|
||||
<u-input v-model="newPassword" type="number" placeholder="请输入6位数字密码" maxlength="6" :border="false"
|
||||
:password="!showNewPassword" @input="handleInput($event, 'newPassword')" />
|
||||
<u-icon :name="showNewPassword ? 'eye-off' : 'eye-fill'" size="20" color="#999"
|
||||
@click="showNewPassword = !showNewPassword" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 确认密码 -->
|
||||
<view class="form-item">
|
||||
<text class="label">确认密码:</text>
|
||||
<view class="input-wrapper">
|
||||
<u-input v-model="confirmPassword" type="number" :border="false" placeholder="请再次输入密码" maxlength="6"
|
||||
:password="!showConfirmPassword" @input="handleInput($event, 'confirmPassword')" />
|
||||
<u-icon :name="showConfirmPassword ? 'eye-off' : 'eye-fill'" size="20" color="#999"
|
||||
@click="showConfirmPassword = !showConfirmPassword" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<view class="footer">
|
||||
<button :class="{ 'primary-button': isFormValid, 'disabled-button': !isFormValid }" :disabled="!isFormValid"
|
||||
@click.stop='handleConfirm'>
|
||||
完成
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const popup = ref<any>(null)
|
||||
|
||||
// 密码显示状态 - 默认都是不可见的
|
||||
const showOldPassword = ref(false)
|
||||
const showNewPassword = ref(false)
|
||||
const showConfirmPassword = ref(false)
|
||||
|
||||
// 重置密码可见性
|
||||
const resetPasswordVisibility = () => {
|
||||
showOldPassword.value = false
|
||||
showNewPassword.value = false
|
||||
showConfirmPassword.value = false
|
||||
}
|
||||
|
||||
// 表单数据
|
||||
const oldPassword = ref('')
|
||||
const newPassword = ref('')
|
||||
const confirmPassword = ref('')
|
||||
|
||||
// 是否有旧密码(是否已开启支付密码)
|
||||
const hasOldPassword = ref(false)
|
||||
|
||||
// 是否关闭支付密码
|
||||
const isClosePassword = ref(false)
|
||||
|
||||
// 获取弹框标题
|
||||
const getDialogTitle = computed(() => {
|
||||
if (!hasOldPassword.value) return '设置支付密码'
|
||||
if (isClosePassword.value) return '关闭支付密码'
|
||||
return '修改支付密码'
|
||||
})
|
||||
|
||||
// 表单验证逻辑更新
|
||||
const isFormValid = computed(() => {
|
||||
if (isClosePassword.value) {
|
||||
// 关闭支付密码时,只要有开关就可以点击完成
|
||||
return true
|
||||
} else if (!hasOldPassword.value) {
|
||||
// 首次设置密码
|
||||
if (!newPassword.value || !confirmPassword.value) return false
|
||||
if (newPassword.value.length !== 6 || confirmPassword.value.length !== 6) return false
|
||||
return newPassword.value === confirmPassword.value
|
||||
} else {
|
||||
// 修改密码
|
||||
if (!oldPassword.value || !newPassword.value || !confirmPassword.value) return false
|
||||
if (oldPassword.value.length !== 6 || newPassword.value.length !== 6 || confirmPassword.value.length !== 6) return false
|
||||
return newPassword.value === confirmPassword.value
|
||||
}
|
||||
})
|
||||
|
||||
// 处理输入,限制只能输入数字且最多6位
|
||||
const handleInput = (value: string, field: 'oldPassword' | 'newPassword' | 'confirmPassword') => {
|
||||
// 只保留数字且最多6位
|
||||
const numericValue = value?.replace(/[^\d]/g, '').slice(0, 6)
|
||||
|
||||
// 更新对应字段的值
|
||||
switch (field) {
|
||||
case 'oldPassword':
|
||||
oldPassword.value = numericValue
|
||||
break
|
||||
case 'newPassword':
|
||||
newPassword.value = numericValue
|
||||
break
|
||||
case 'confirmPassword':
|
||||
confirmPassword.value = numericValue
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 生成随机6位数字
|
||||
const generateRandomPassword = () => {
|
||||
return Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
|
||||
}
|
||||
|
||||
// 重置表单更新
|
||||
const resetForm = () => {
|
||||
oldPassword.value = ''
|
||||
newPassword.value = ''
|
||||
confirmPassword.value = ''
|
||||
resetPasswordVisibility()
|
||||
isClosePassword.value = false
|
||||
}
|
||||
|
||||
// 显示弹框
|
||||
const show = async () => {
|
||||
hasOldPassword.value = userStore.userInfo.paywithpwd === 1
|
||||
isClosePassword.value = false
|
||||
resetPasswordVisibility()
|
||||
popup.value?.open('center')
|
||||
}
|
||||
|
||||
// 隐藏弹框
|
||||
const hide = () => {
|
||||
popup.value?.close()
|
||||
resetForm()
|
||||
}
|
||||
|
||||
// 确认按钮处理更新
|
||||
const handleConfirm = async () => {
|
||||
try {
|
||||
await userStore.setPayPassword({
|
||||
paywithpwd: isClosePassword.value ? 0 : 1,
|
||||
oldpwd: hasOldPassword.value ? oldPassword.value : '',
|
||||
newpwd: isClosePassword.value ? '' : newPassword.value,
|
||||
})
|
||||
// 更新本地状态
|
||||
userStore.userInfo.paywithpwd = isClosePassword.value ? 0 : 1
|
||||
uni.showToast({
|
||||
title: isClosePassword.value ? '已关闭支付密码' : '设置成功',
|
||||
icon: 'success',
|
||||
})
|
||||
hide()
|
||||
resetForm()
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '操作失败',
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 处理开关切换
|
||||
const handleSwitchChange = (value: boolean) => {
|
||||
isClosePassword.value = value
|
||||
// 切换时重置密码输入
|
||||
if (value) {
|
||||
newPassword.value = ''
|
||||
confirmPassword.value = ''
|
||||
oldPassword.value = generateRandomPassword() // 生成随机6位数字
|
||||
resetPasswordVisibility()
|
||||
} else {
|
||||
oldPassword.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
// 暴露方法给父组件使用
|
||||
defineExpose({
|
||||
show,
|
||||
hide
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.pay-password-dialog {
|
||||
width: 600rpx;
|
||||
padding: 40rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 24rpx;
|
||||
position: relative;
|
||||
|
||||
.dialog-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 40rpx;
|
||||
|
||||
.title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.form-container {
|
||||
.switch-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
margin-bottom: 20rpx;
|
||||
|
||||
text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
.label {
|
||||
font-size: 30rpx;
|
||||
color: #333;
|
||||
margin-bottom: 16rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx;
|
||||
height: 50rpx;
|
||||
|
||||
:deep(.u-border) {
|
||||
border-style: hidden;
|
||||
}
|
||||
|
||||
:deep(.u-input) {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
font-size: 10rpx;
|
||||
}
|
||||
|
||||
:deep(.u-input__input) {
|
||||
height: 100%;
|
||||
line-height: 60rpx;
|
||||
font-size: 10rpx;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
@@ -66,7 +66,7 @@ const buildSignParams = computed(() => {
|
||||
return sortASCII({
|
||||
client_sn: props.payParams.client_sn || '',
|
||||
return_url: props.payParams.return_url,
|
||||
total_amount: (props.payParams.total_amount * 100).toString(),
|
||||
total_amount: Number((props.payParams.total_amount * 100).toFixed(2)),
|
||||
terminal_sn: props.payParams.terminal_sn,
|
||||
subject: props.payParams.subject,
|
||||
subject_img: props.payParams.subject_img,
|
||||
|
@@ -3,9 +3,12 @@
|
||||
<view class='content'>
|
||||
<view class='c-flex-row' style='align-items: flex-start'>
|
||||
<image class='goods-image' :src='goodsDetailBean?.images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1'>
|
||||
<text class='goods-name'>{{ goodsDetailBean?.name }}</text>
|
||||
<text class='goods-price'>{{ flashPrice > 0 ? `${flashPrice}` : `${goodsDetailBean?.price}` || 0 }}</text>
|
||||
<view class='c-flex-column' style='flex: 1;display: inline-grid'>
|
||||
<text class='goods-name'>{{ goodsDetailBean?.name || '未知' }}</text>
|
||||
<text class='goods-price'>
|
||||
{{ flashPrice > 0 ? `${flashPrice}` : `${goodsDetailBean?.consumePrice || 0}` || 0
|
||||
}}
|
||||
</text>
|
||||
</view>
|
||||
<image class='close-image' :src='assetsUrl("ic_close.png")' @click.stop='close' />
|
||||
</view>
|
||||
@@ -16,7 +19,7 @@
|
||||
:class='{"sku-item-active":currentColorIndex==index}'
|
||||
v-for='(item, index) in skuColorList' :key='index'
|
||||
@click='colorChange(index)'>
|
||||
<text>{{ item }}</text>
|
||||
<text>{{ item||'均色' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -27,7 +30,7 @@
|
||||
:class='{"sku-item-active":currentSizeIndex==index,"sku-item-disabled":item.existingNumber<=0}'
|
||||
v-for='(item, index) in skuSizeList' :key='index'
|
||||
@click='sizeChange(index)'>
|
||||
<text>{{ item.sizeName }}</text>
|
||||
<text>{{ item.sizeName||'均码' }}</text>
|
||||
</view>
|
||||
<text v-else style='color: #999999;font-size: 30rpx'>暂无库存</text>
|
||||
</view>
|
||||
@@ -44,7 +47,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<button class='primary-button' :plain='currentSizeIndex<=0' :disabled='currentSizeIndex<=0' @click='confirm'>
|
||||
<button class='primary-button' :plain='currentSizeIndex<0' :disabled='currentSizeIndex<0' @click='confirm'>
|
||||
确定
|
||||
</button>
|
||||
</view>
|
||||
@@ -58,6 +61,10 @@ import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import { showToast } from '@/utils';
|
||||
import { getGoodsDetail } from '@/api/goods';
|
||||
import { GoodsBean, StockBean } from '@/api/goods/types';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
|
||||
const props = defineProps({
|
||||
flashPrice: {
|
||||
@@ -78,7 +85,10 @@ const show = async (goodsId: string, fn: Function) => {
|
||||
callback = fn;
|
||||
|
||||
goodsDetailBean.value = await getGoodsDetail(goodsId);
|
||||
if(goodsDetailBean.value?.stocks?.length == 0) {
|
||||
goodsDetailBean.value.price = userStore.getRealGoodsPrice(goodsDetailBean.value?.price,goodsDetailBean.value?.priceExt)
|
||||
goodsDetailBean.value.consumePrice = Number((goodsDetailBean.value?.price * userInfo?.value.userDiscount).toFixed(2));
|
||||
|
||||
if((goodsDetailBean.value?.stocks?.length || 0) <= 0) {
|
||||
showToast('暂无库存');
|
||||
return;
|
||||
}
|
||||
@@ -103,6 +113,7 @@ const show = async (goodsId: string, fn: Function) => {
|
||||
}
|
||||
|
||||
if(skuSizeList) {
|
||||
// skuSizeList.value![0].existingNumber = 2;
|
||||
// skuSizeList.value![2].existingNumber = 2;
|
||||
}
|
||||
};
|
||||
@@ -180,6 +191,7 @@ defineExpose({
|
||||
color: #333333;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.goods-price {
|
||||
|
@@ -2,8 +2,8 @@
|
||||
"name": "SUKE-MP",
|
||||
"appid": "",
|
||||
"description": "",
|
||||
"versionName": "1.0.0",
|
||||
"versionCode": "100",
|
||||
"versionName": "3.0.4",
|
||||
"versionCode": "304",
|
||||
"transformPx": false,
|
||||
"app-plus": {
|
||||
"usingComponents": true,
|
||||
@@ -19,15 +19,13 @@
|
||||
},
|
||||
"mp-weixin": {
|
||||
"appid": "wx92e663dc11d0c0a8",
|
||||
// "appid": "wx67a750d0ceed4d88",
|
||||
"setting": {
|
||||
"urlCheck": false
|
||||
},
|
||||
"usingComponents": true,
|
||||
|
||||
"plugins": {
|
||||
"sqb-pay": {
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"provider": "wx55540b288c5ce319"
|
||||
}
|
||||
}
|
||||
@@ -42,4 +40,4 @@
|
||||
"base": "/uniapp-vue3-template/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,7 +4,8 @@
|
||||
"^u--(.*)": "uview-plus/components/u-$1/u-$1.vue",
|
||||
"^up-(.*)": "uview-plus/components/u-$1/u-$1.vue",
|
||||
"^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue",
|
||||
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue"
|
||||
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue",
|
||||
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
|
||||
}
|
||||
},
|
||||
"pages": [
|
||||
@@ -36,7 +37,13 @@
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "肃客会员"
|
||||
"navigationBarTitleText": "VIP顾客中心"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/coupons/ticketsBuy/ticketsBuy",
|
||||
"style": {
|
||||
"navigationBarTitleText": "团购详情"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -50,6 +57,12 @@
|
||||
},
|
||||
{
|
||||
"path": "register/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户注册"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "register/reward",
|
||||
"style": {
|
||||
"navigationBarTitleText": "注册有礼"
|
||||
}
|
||||
@@ -79,6 +92,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "groupbuy/order-coupon-confirm",
|
||||
"style": {
|
||||
"navigationBarTitleText": "确认订单",
|
||||
"usingComponents": {
|
||||
"sqb-pay": "plugin://sqb-pay/sqb-pay"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "webview/index",
|
||||
"navigationBarTitleText": "网页"
|
||||
@@ -196,6 +218,12 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "新增收货地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "contact/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "联系商家"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -2,13 +2,13 @@
|
||||
<view class='content'>
|
||||
<view class='swiper-container'>
|
||||
<swiper class='swiper' :interval='1500' :duration='1000' @change='swiperChange'>
|
||||
<swiper-item v-for='(item,index) in bannerList' :key='index'>
|
||||
<image :src='item||defaultImage' />
|
||||
<swiper-item v-for='(item,index) in bannerList||[defaultImage]' :key='index'>
|
||||
<image :src='item' mode='aspectFill' />
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class='indicator'>
|
||||
<text>{{ swiperIndex + 1 }}</text>
|
||||
<text>/{{ bannerList.length }}</text>
|
||||
<text>/{{ bannerList?.length || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class='countdown c-flex-row'>
|
||||
@@ -17,9 +17,9 @@
|
||||
</view>
|
||||
<view class='price c-flex-column' style='flex: 1'>
|
||||
<text>{{ groupBuyBean?.payPrice || 0 }}</text>
|
||||
<text>¥{{ groupBuyBean?.price || 0 }}</text>
|
||||
<text v-if='(groupBuyBean?.price||0)>0&&!isCouponGoodsDetail'>¥{{ groupBuyBean?.price || 0 }}</text>
|
||||
</view>
|
||||
<view class='countdown-time c-flex-column'>
|
||||
<view v-if='isPending()' class='countdown-time c-flex-column'>
|
||||
<view class='c-flex-row'>{{ countdownTime?.days || 0 }}天
|
||||
<text class='time'>{{ countdownTime?.hours || '00' }}</text>
|
||||
:
|
||||
@@ -29,6 +29,11 @@
|
||||
</view>
|
||||
<text>距离活动结束仅剩</text>
|
||||
</view>
|
||||
<view v-else>
|
||||
<text style='font-size: 35rpx;color: #FFFFFF'>
|
||||
{{ isNotStated() ? '未开始' : '已结束' }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='goods-info-view c-flex-column'>
|
||||
@@ -38,7 +43,7 @@
|
||||
</view>
|
||||
|
||||
<view class='c-flex-row'>
|
||||
<text style='flex: 1'>{{ groupBuyBean?.name }}</text>
|
||||
<text style='flex: 1'>{{ groupBuyBean?.name || '未知' }}</text>
|
||||
<view class='share-button c-flex-column'>
|
||||
<image :src='assetsUrl("ic_share.png")'></image>
|
||||
<button class='btn' plain open-type='share'>分享</button>
|
||||
@@ -46,7 +51,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='goods-sku-view c-flex-column'>
|
||||
<view class='goods-sku-view c-flex-column' v-if='groupBuyBean?.goods'>
|
||||
<view class='c-flex-row' @click.stop='showSkuDialog'>
|
||||
<text>选择</text>
|
||||
<text>规格 颜色/尺码</text>
|
||||
@@ -55,14 +60,14 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='recommend-view c-flex-column' v-if='recommendList?.length>0'>
|
||||
<view class='recommend-view c-flex-column' v-if='(recommendList?.length||0)>0'>
|
||||
<text>浏览此商品的客户还浏览了</text>
|
||||
<scroll-view scroll-x>
|
||||
<view style='display: inline-block' v-for='(item, index) in recommendList'
|
||||
:key='index'>
|
||||
<view class='recommend-item c-flex-column'>
|
||||
<image :src='item.images' />
|
||||
<text>{{ item.goodsName }}</text>
|
||||
<image :src='item.images||defaultImage' />
|
||||
<text>{{ item.goodsName || '未知' }}</text>
|
||||
<text class='goods-price'>{{ item.price }}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -72,13 +77,16 @@
|
||||
<!-- 商品详情图片 -->
|
||||
<view class='card-view image-container' v-if='groupBuyBean?.content'>
|
||||
<text class='card-view-title'>商品详情</text>
|
||||
<image
|
||||
v-for='(item,index) in JSON.parse(groupBuyBean?.content).filter((a: any) => a.type === 2).map((b: any) => b.images)'
|
||||
:src='item' mode='aspectFill' :key='index' />
|
||||
<text v-if='isCouponGoodsDetail' style='padding: 20rpx 35rpx;font-size: 30rpx'>
|
||||
{{ groupBuyBean?.content }}
|
||||
</text>
|
||||
<image v-else
|
||||
v-for='(item,index) in JSON.parse(groupBuyBean?.content).filter((a: any) => a.type === 2).map((b: any) => b.images)'
|
||||
:src='item' mode='aspectFill' :key='index' />
|
||||
</view>
|
||||
|
||||
<!-- 商品详情 -->
|
||||
<view class='card-view goods-container'>
|
||||
<view class='card-view goods-container' v-if='groupBuyBean?.goods'>
|
||||
<view class='c-flex-row'>
|
||||
<image :src='groupBuyBean?.goods?.images' />
|
||||
<view class='c-flex-column'>
|
||||
@@ -96,7 +104,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 商品详情优惠券 -->
|
||||
<view class='card-view coupon-container'>
|
||||
<view class='card-view coupon-container' v-if='groupBuyBean?.couponsList&&groupBuyBean?.couponsList?.length>0'>
|
||||
<text class='card-view-title'>赠送优惠券</text>
|
||||
<view class='c-flex-column'>
|
||||
<coupon-item v-for='(item,index) in groupBuyBean?.couponsList' :key='index' :item='item' />
|
||||
@@ -104,7 +112,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 商品详情跟团记录 -->
|
||||
<view class='card-view record-container'>
|
||||
<view class='card-view record-container' v-if='recordList&&(recordList?.length||0)>0'>
|
||||
<text class='card-view-title'>跟团记录</text>
|
||||
<u-list :list='recordList' :border='false' @scrolltolower='loadMore'>
|
||||
<u-list-item v-for='(item,index) in recordList' :key='index'>
|
||||
@@ -122,7 +130,10 @@
|
||||
</view>
|
||||
|
||||
<view class='bottom-view c-flex-row'>
|
||||
<view class='place-order-button' @click.stop='placeOrder'>跟团购买</view>
|
||||
<button v-if='isPending()' class='place-order-button' @click.stop='placeOrder'>跟团购买</button>
|
||||
<button v-else class='place-order-button-disable' :plain='true' :disabled='true'>
|
||||
{{ isNotStated() ? '即将开始' : '已结束' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<sku-dialog ref='skuDialogRef' :flash-price='Number(groupBuyBean?.payPrice) || 0' />
|
||||
@@ -131,15 +142,22 @@
|
||||
<script lang='ts' setup>
|
||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import dayjs from 'dayjs';
|
||||
import { formatTimeWithZeroPad, goPath, isLogin } from '@/utils';
|
||||
import { formatTimeWithZeroPad, getCompanyId, getOpenId, goLogin, goPath, isLogin, showToast } from '@/utils';
|
||||
import SkuDialog from '@/components/sku-dialog.vue';
|
||||
import CouponItem from './components/coupon-item.vue';
|
||||
|
||||
import { getGroupBuyDetail, getGroupBuyRecordList, preOrder } from '@/api/groupbuy';
|
||||
import {
|
||||
getGroupBuyDetail,
|
||||
getGroupBuyRecordList,
|
||||
getShareGoodsCouponDetail,
|
||||
getShareGoodsDetail,
|
||||
preOrderV2
|
||||
} from '@/api/groupbuy';
|
||||
import { getGoodsList } from '@/api/goods';
|
||||
import { GoodsBean } from '@/api/goods/types';
|
||||
import { useUserStore } from '@/store';
|
||||
import { GroupBuyBean, RecordBean } from '@/api/groupbuy/types';
|
||||
import { getCompanyList } from '@/api/company';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
@@ -147,6 +165,7 @@ const { userInfo } = storeToRefs(userStore);
|
||||
const skuDialogRef = ref();
|
||||
const groupBuyBean = ref<GroupBuyBean>();
|
||||
const recommendList = ref<GoodsBean[]>();
|
||||
const isCouponGoodsDetail = ref(false);
|
||||
|
||||
const bannerList = ref([]);
|
||||
const swiperIndex = ref(0);
|
||||
@@ -161,17 +180,79 @@ const countdownTime = ref<{
|
||||
|
||||
const recordList = ref<RecordBean[]>([]);
|
||||
const currentPageNum = ref(1);
|
||||
const shareGoodsId = ref();
|
||||
const shareCouponId = ref();
|
||||
|
||||
onLoad(async (e: any) => {
|
||||
if(isLogin()) {
|
||||
await uni.showLoading();
|
||||
groupBuyBean.value = await getGroupBuyDetail(e.id);
|
||||
groupBuyBean.value.goods.price = groupBuyBean.value.price;
|
||||
bannerList.value = JSON.parse(groupBuyBean.value.content).filter((item: any) => item.type === 2).map((item: any) => item.images);
|
||||
countdown();
|
||||
await fetchRecommendList();
|
||||
await fetchBuyRecordList();
|
||||
if(e.id != undefined) {
|
||||
groupBuyBean.value = await getGroupBuyDetail(e.id);
|
||||
}
|
||||
if(e.shareId != undefined) {
|
||||
shareGoodsId.value = e.shareId;
|
||||
const { group, share } = await getShareGoodsDetail(e.shareId);
|
||||
groupBuyBean.value = group;
|
||||
}
|
||||
if(e.couponId != undefined) {
|
||||
shareCouponId.value = e.couponId;
|
||||
isCouponGoodsDetail.value = true;
|
||||
groupBuyBean.value = await getShareGoodsCouponDetail(e.couponId);
|
||||
groupBuyBean.value.price = groupBuyBean.value?.offsetPrice;
|
||||
bannerList.value = groupBuyBean.value?.image?.split(',');
|
||||
}
|
||||
|
||||
const maOpenId = getOpenId() || userInfo.value?.maOpenId;
|
||||
const data = await getCompanyList(maOpenId);
|
||||
const companyList = data.map((item: any) => item.company);
|
||||
const userList = data.map((item: any) => item.user);
|
||||
let index = companyList.findIndex((res: {
|
||||
id: string
|
||||
}) => res.id === (getApp()?.globalData?.shareCompanyId || getCompanyId()));
|
||||
if(index < 0) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '当前店铺还未注册,请先注册',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm) {
|
||||
goPath('/pages/common/register/index');
|
||||
} else {
|
||||
goPath('/pages/home/index');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await userStore.setUserInfo(userList[index]);
|
||||
}
|
||||
|
||||
// setCompanyId('1512403904150138881');
|
||||
// groupBuyBean.value = await getGroupBuyDetail('1740922051118063618');
|
||||
if(groupBuyBean.value) {
|
||||
countdown();
|
||||
if(e.couponId === undefined) {
|
||||
groupBuyBean.value.goods.price = groupBuyBean.value?.price || 0;
|
||||
bannerList.value = JSON.parse(groupBuyBean.value?.content)?.filter((item: any) => item.type === 2).map((item: any) => item.images);
|
||||
await fetchRecommendList();
|
||||
await fetchBuyRecordList();
|
||||
}
|
||||
} else {
|
||||
showToast('查询失败', {
|
||||
complete: () => {
|
||||
const pages = getCurrentPages();
|
||||
if(pages.map(item => item?.route?.includes('pages/home/index'))) {
|
||||
uni.navigateBack();
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/index'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
uni.hideLoading();
|
||||
} else {
|
||||
goLogin(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -181,10 +262,35 @@ onUnload(() => {
|
||||
}
|
||||
});
|
||||
|
||||
onShareAppMessage((e) => {
|
||||
let path = `/pages/common/groupbuy/detail?id=${groupBuyBean.value?.id}&companyId=${getApp().globalData?.companyId}&storeId=${getApp().globalData?.storeId}`;
|
||||
if(shareGoodsId.value) {
|
||||
path = `/pages/common/groupbuy/detail?shareId=${shareGoodsId.value}&companyId=${getApp().globalData?.companyId}&storeId=${getApp().globalData?.storeId}`;
|
||||
} else if(shareCouponId.value) {
|
||||
path = `/pages/common/groupbuy/detail?couponId=${shareCouponId.value}&companyId=${getApp().globalData?.companyId}&storeId=${getApp().globalData?.storeId}`;
|
||||
}
|
||||
return {
|
||||
title: groupBuyBean.value?.goods?.name || 'VIP顾客中心',
|
||||
path: path
|
||||
};
|
||||
});
|
||||
|
||||
const isNotStated = () => {
|
||||
return dayjs(groupBuyBean.value?.startDate).isAfter(Date.now());
|
||||
};
|
||||
|
||||
const isPending = () => {
|
||||
return dayjs(groupBuyBean.value?.startDate).isBefore(Date.now()) && dayjs(groupBuyBean.value?.endDate).isAfter(Date.now());
|
||||
};
|
||||
|
||||
const isEnded = () => {
|
||||
return dayjs(groupBuyBean.value?.endDate).isBefore(Date.now());
|
||||
};
|
||||
|
||||
const getStockColorCount = computed(() => {
|
||||
const list = Array.from(new Set(groupBuyBean.value?.goods?.stocks?.map(item => item.colorName)))
|
||||
.map(colorName => groupBuyBean.value?.goods?.stocks?.find(item => item.colorName === colorName)!);
|
||||
return list.length;
|
||||
return (list?.length) || 0;
|
||||
});
|
||||
|
||||
const fetchRecommendList = async () => {
|
||||
@@ -194,7 +300,7 @@ const fetchRecommendList = async () => {
|
||||
pageSize: 20,
|
||||
bean: {
|
||||
keyword: '',
|
||||
typeIds: ['1724629185362591745']
|
||||
typeIds: []
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -243,7 +349,8 @@ const showSkuDialog = (fn: Function) => {
|
||||
|
||||
const placeOrder = async () => {
|
||||
|
||||
async function create(bean: GoodsBean) {
|
||||
async function createGoodsOrder(bean: GoodsBean) {
|
||||
await uni.showLoading();
|
||||
const params = {
|
||||
'colorId': bean.checkedStock.colorId,
|
||||
'sizeId': bean.checkedStock.sizeId,
|
||||
@@ -253,13 +360,18 @@ const placeOrder = async () => {
|
||||
'shareId': '123456'
|
||||
};
|
||||
|
||||
const result = await preOrder(params);
|
||||
const result = await preOrderV2(params);
|
||||
uni.hideLoading();
|
||||
goPath(`/pages/common/groupbuy/order-confirm?orderBean=${encodeURIComponent(JSON.stringify(result))}`);
|
||||
}
|
||||
|
||||
showSkuDialog((e: GoodsBean) => {
|
||||
create(e);
|
||||
});
|
||||
if(isCouponGoodsDetail.value) {
|
||||
goPath(`/pages/common/groupbuy/order-coupon-confirm?bean=${encodeURIComponent(JSON.stringify(groupBuyBean.value))}`);
|
||||
} else {
|
||||
showSkuDialog((e: GoodsBean) => {
|
||||
createGoodsOrder(e);
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -550,6 +662,13 @@ const placeOrder = async () => {
|
||||
background: #F32B2B;
|
||||
color: #FFFFFF;
|
||||
border-radius: 40rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.place-order-button-disable {
|
||||
@extend .place-order-button;
|
||||
background: #b9b5b5;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,6 +695,8 @@ const placeOrder = async () => {
|
||||
.goods-container {
|
||||
padding: 30rpx;
|
||||
position: relative;
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
|
||||
image {
|
||||
width: 200rpx;
|
||||
@@ -618,7 +739,14 @@ const placeOrder = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
.coupon-container {
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.record-container {
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
|
||||
.item-view {
|
||||
margin: 10rpx 30rpx;
|
||||
@@ -633,18 +761,19 @@ const placeOrder = async () => {
|
||||
margin: 0 15rpx;
|
||||
|
||||
text:nth-of-type(1) {
|
||||
font-size: 20rpx;
|
||||
font-size: 25rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
text:nth-of-type(2) {
|
||||
font-size: 15rpx;
|
||||
font-size: 25rpx;
|
||||
color: #666666;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
text:nth-of-type(1) {
|
||||
font-size: 30rpx;
|
||||
color: #F32B2B;
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<!-- <u-list-item v-for='(item,index) in groupbuyList' :key='index'>-->
|
||||
<view class='c-flex-column' v-for='(item,index) in groupbuyList' :key='index'>
|
||||
<view class='item c-flex-row' @click.stop='goPath(`/pages/common/groupbuy/detail?id=${item.id}`)'>
|
||||
<image class='goods-image' :src='JSON.parse(item.content)[0].images||defaultImage' />
|
||||
<image class='goods-image' mode='aspectFill' :src='JSON.parse(item.content)[0].images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1'>
|
||||
<view class='goods-name'>{{ item.name }}</view>
|
||||
<view class='middle-view c-flex-row'>
|
||||
@@ -19,7 +19,7 @@
|
||||
<image :src='assetsUrl("ic_decline.png")' />
|
||||
<text>直降¥{{ (item.price - item.payPrice).toFixed(2) }}</text>
|
||||
</view>
|
||||
<text>即将恢复</text>
|
||||
<text>{{ tabIndex == 0 ? '即将恢复' : '即将开始' }}</text>
|
||||
</view>
|
||||
<view class='bottom-price c-flex-row' :class='{"bottom-price-disabled":tabIndex==1}'>
|
||||
<text>{{ item.payPrice }}</text>
|
||||
@@ -31,6 +31,8 @@
|
||||
</view>
|
||||
<!-- </u-list-item>-->
|
||||
<!-- </u-list>-->
|
||||
|
||||
<u-empty v-if='groupbuyList.length === 0' text='暂无团购活动' marginTop='100' />
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -62,7 +64,7 @@ const fetchData = async (refresh: boolean = true) => {
|
||||
pageNum: currentPageNum.value,
|
||||
pageSize: 100,
|
||||
obj: {
|
||||
status: tabIndex.value
|
||||
timeStatus: tabIndex.value + 1
|
||||
}
|
||||
});
|
||||
groupbuyList.value = list;
|
||||
@@ -112,6 +114,7 @@ const loadMore = () => {
|
||||
|
||||
.scroll-view {
|
||||
background: #FFFFFF;
|
||||
height: 100vh;
|
||||
|
||||
.item {
|
||||
padding: 20rpx 30rpx 40rpx 30rpx;
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<view class='content'>
|
||||
|
||||
<view class='card-view'>
|
||||
<template class='c-flex-row' v-for='item in orderBean?.orderGoods' :key='item.id'>
|
||||
<image class='goods-image' :src='item?.images||defaultImage' />
|
||||
@@ -46,7 +45,7 @@
|
||||
<script lang='ts' setup>
|
||||
import { pay, progress } from '@/api/groupbuy';
|
||||
import { OrderBean } from '@/api/order/types';
|
||||
import { parseParameter, sortASCII } from '@/utils';
|
||||
import { parseParameter, showToast, sortASCII } from '@/utils';
|
||||
import { hexMD5 } from '@/utils/common/md5';
|
||||
import { useUserStore } from '@/store';
|
||||
import { handlePayResult } from '@/utils/order';
|
||||
@@ -57,19 +56,23 @@ const { terminalInfo } = storeToRefs(userState);
|
||||
|
||||
const orderBean = ref<OrderBean>();
|
||||
|
||||
onLoad((e: any) => {
|
||||
onLoad(async (e: any) => {
|
||||
orderBean.value = JSON.parse(decodeURIComponent(e?.orderBean));
|
||||
await userState.fetchTerminal();
|
||||
if(!terminalInfo.value) {
|
||||
showToast('当前店铺未配置收款渠道,请联系商家');
|
||||
}
|
||||
});
|
||||
|
||||
const buildSqbParams = computed(() => {
|
||||
const params = sortASCII({
|
||||
client_sn: orderBean.value?.id || '',
|
||||
return_url: '/pages/common/payresult/index',
|
||||
total_amount: ((orderBean.value?.totalPrice || 0) * 100).toString(),
|
||||
terminal_sn: terminalInfo.value.terminalSn,
|
||||
subject: '商品团购券',
|
||||
subject_img: orderBean?.value?.orderGoods[0].images || '',
|
||||
merchant_name: terminalInfo.value.companyName,
|
||||
total_amount: Number(((orderBean.value?.totalPrice || 0) * 100).toFixed(2)),
|
||||
terminal_sn: terminalInfo.value?.terminalSn,
|
||||
subject: orderBean?.value?.orderGoods[0]?.goodsName || '商品团购券',
|
||||
subject_img: orderBean?.value?.orderGoods[0]?.images || 'xxx',
|
||||
merchant_name: terminalInfo.value?.companyName,
|
||||
notify_url: 'https://www.baidu.com'
|
||||
}, true);
|
||||
|
||||
@@ -81,16 +84,35 @@ const buildSqbParams = computed(() => {
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.id, e, {
|
||||
onSuccess: () => {
|
||||
pay({
|
||||
'orderId': orderBean.value?.id,
|
||||
'result': 'xxx'
|
||||
onSuccess: (options: any) => {
|
||||
showToast('支付成功', {
|
||||
icon: 'success',
|
||||
complete: () => {
|
||||
pay({
|
||||
'orderId': orderBean.value?.id,
|
||||
'result': 'xxx'
|
||||
}).then(res => {
|
||||
uni.navigateBack();
|
||||
});
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
},
|
||||
onFailure: (e: any) => {
|
||||
showToast(e, {
|
||||
complete: () => {
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const payment = () => {
|
||||
if(!terminalInfo.value) {
|
||||
showToast('当前店铺未配置收款渠道,请联系商家');
|
||||
return;
|
||||
}
|
||||
const params = {
|
||||
'id': orderBean.value?.id,
|
||||
'orderSn': buildSqbParams.value.client_sn,
|
||||
|
299
src/pages/common/groupbuy/order-coupon-confirm.vue
Normal file
299
src/pages/common/groupbuy/order-coupon-confirm.vue
Normal file
@@ -0,0 +1,299 @@
|
||||
<template>
|
||||
<view class='content'>
|
||||
<view class='card-view' style='justify-content: flex-start'>
|
||||
<view class='c-flex-row' style='align-items: center;flex: 1'>
|
||||
<image class='goods-image' :src='imageList?.length>0?imageList[0]:defaultImage' />
|
||||
<view class='c-flex-column' style='margin-left: 10rpx;flex: 1'>
|
||||
<text class='goods-name'>{{ groupBuyBean?.name || groupBuyBean?.title }}</text>
|
||||
<text class='date'>{{ groupBuyBean?.startDate }}至{{ groupBuyBean?.endDate }}</text>
|
||||
</view>
|
||||
<text class='goods-price'>¥{{ groupBuyBean?.payPrice }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='card-view'>
|
||||
<text style='flex: 1'>数量</text>
|
||||
|
||||
<view class='count-change-view c-flex-row'>
|
||||
<view class='count-image' @click.stop='countChange(false)'>
|
||||
<image :src='assetsUrl("ic_reduce.png")' />
|
||||
</view>
|
||||
<text>{{ goodsCount }}</text>
|
||||
<view class='count-image' @click.stop='countChange(true)'>
|
||||
<image :src='assetsUrl("ic_plus.png")' />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='card-view'>
|
||||
<text style='flex: 1'>实付</text>
|
||||
<text style='color: #F32B2B'>¥{{ totalPrice || 0 }}</text>
|
||||
</view>
|
||||
|
||||
<view class='bottom-view c-flex-row'>
|
||||
<sqb-pay @navigateTo='navigateTo'
|
||||
:return_url='buildSqbParams.return_url'
|
||||
:total_amount='buildSqbParams.total_amount'
|
||||
:terminal_sn='buildSqbParams.terminal_sn'
|
||||
:client_sn='buildSqbParams.client_sn'
|
||||
:subject='buildSqbParams.subject'
|
||||
:subject_img='buildSqbParams.subject_img '
|
||||
:merchant_name='buildSqbParams.merchant_name'
|
||||
:notify_url='buildSqbParams.notify_url'
|
||||
:sign='buildSqbParams.sign'>
|
||||
<button class='confirm-button' @click='payment'>支付</button>
|
||||
</sqb-pay>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { couponPay, preOrder } from '@/api/groupbuy';
|
||||
import { OrderBean } from '@/api/order/types';
|
||||
import { parseParameter, showToast, sortASCII } from '@/utils';
|
||||
import { hexMD5 } from '@/utils/common/md5';
|
||||
import { useUserStore } from '@/store';
|
||||
import { handlePayResult } from '@/utils/order';
|
||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import { GroupBuyBean } from '@/api/groupbuy/types';
|
||||
|
||||
const userState = useUserStore();
|
||||
const { userInfo, terminalInfo } = storeToRefs(userState);
|
||||
|
||||
const groupBuyBean = ref<GroupBuyBean>();
|
||||
const imageList = ref([]);
|
||||
const orderBean = ref<OrderBean>();
|
||||
const goodsCount = ref(1);
|
||||
|
||||
onLoad(async (e: any) => {
|
||||
try {
|
||||
groupBuyBean.value = JSON.parse(decodeURIComponent(e?.bean));
|
||||
if(groupBuyBean.value) {
|
||||
imageList.value = groupBuyBean.value?.image?.split(',');
|
||||
}
|
||||
await userState.fetchTerminal(groupBuyBean.value?.companyId || '');
|
||||
createOrder();
|
||||
} catch (e) {
|
||||
getApp().globalData?.logger?.error('order-coupon-confirm: exception ', e);
|
||||
}
|
||||
});
|
||||
|
||||
const countChange = (isPlus: boolean) => {
|
||||
if(isPlus) {
|
||||
if(goodsCount.value < (groupBuyBean.value?.publicNum || 0)) {
|
||||
goodsCount.value += 1;
|
||||
} else {
|
||||
showToast('超出最大购买数量');
|
||||
}
|
||||
} else {
|
||||
if(goodsCount.value > 1) {
|
||||
goodsCount.value -= 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const totalPrice = computed(() => {
|
||||
return Number(((groupBuyBean.value?.payPrice || 0) * goodsCount.value).toFixed(2));
|
||||
});
|
||||
|
||||
const buildSqbParams = computed(() => {
|
||||
const params = sortASCII({
|
||||
client_sn: orderBean.value?.id || '',
|
||||
return_url: '/pages/common/payresult/index',
|
||||
total_amount: Number(((totalPrice.value || 0) * 100).toFixed(2)),
|
||||
terminal_sn: terminalInfo.value?.terminalSn,
|
||||
subject: groupBuyBean.value?.name || '商品团购券',
|
||||
subject_img: (imageList.value?.length > 0 && imageList.value[0]) || 'xxx',
|
||||
merchant_name: terminalInfo.value?.companyName,
|
||||
notify_url: 'https://www.baidu.com'
|
||||
}, true);
|
||||
|
||||
getApp().globalData?.logger?.info('order-coupon-confirm: buildSqbParams before sign: ', params);
|
||||
const paramsSign = {
|
||||
...params,
|
||||
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value?.terminalKey).toUpperCase()
|
||||
};
|
||||
getApp().globalData?.logger?.info('order-coupon-confirm: buildSqbParams after sign: ', paramsSign);
|
||||
return paramsSign;
|
||||
});
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.id, e, {
|
||||
onSuccess: (options: any) => {
|
||||
showToast('支付成功', {
|
||||
icon: 'success',
|
||||
complete: () => {
|
||||
// delete orderBean.value && orderBean.value!.createTime;
|
||||
couponPay({
|
||||
...orderBean.value,
|
||||
payResult: JSON.stringify(options),
|
||||
status: 2
|
||||
}).then(res => {
|
||||
uni.navigateBack();
|
||||
});
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
},
|
||||
onFailure: (e: any) => {
|
||||
getApp().globalData?.logger?.error('coupon pay failure params: ', buildSqbParams.value, e);
|
||||
|
||||
uni.showToast({
|
||||
title: e,
|
||||
icon: 'none',
|
||||
duration: 1500,
|
||||
complete(result) {
|
||||
if(e?.includes('订单号重复')) {
|
||||
createOrder();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const createOrder = () => {
|
||||
if(!terminalInfo.value) {
|
||||
showToast('当前店铺未配置收款渠道,请联系商家');
|
||||
return;
|
||||
}
|
||||
const params = {
|
||||
id: groupBuyBean.value?.id,
|
||||
cash: totalPrice.value,
|
||||
num: goodsCount.value,
|
||||
memberId: userInfo.value.id,
|
||||
payBo: {
|
||||
terminal_sn: terminalInfo.value?.terminalSn,
|
||||
terminal_key: terminalInfo.value?.terminalKey,
|
||||
merchant_name: userInfo.value.companyName,
|
||||
total_amount: totalPrice.value,
|
||||
subject: groupBuyBean.value?.name || '微信团购券',
|
||||
description: groupBuyBean.value?.title || '微信团购券',
|
||||
subject_img: (imageList.value?.length > 0 && imageList.value[0]) || '',
|
||||
device_id: groupBuyBean.value?.creatorId,
|
||||
return_url: '/pages/payResult/index'
|
||||
}
|
||||
};
|
||||
preOrder(params).then(res => {
|
||||
orderBean.value = res as any;
|
||||
if(orderBean.value) {
|
||||
orderBean.value!.clientSn = res?.id;
|
||||
}
|
||||
}).catch(err => {
|
||||
getApp().globalData?.logger?.error('order-coupon-confirm: preOrder exception ', err);
|
||||
});
|
||||
};
|
||||
|
||||
const payment = () => {
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.content {
|
||||
.card-view:nth-of-type(1) {
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.card-view {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin: 10rpx 30rpx;
|
||||
background: #FFFFFF;
|
||||
font-size: 35rpx;
|
||||
padding: 30rpx;
|
||||
|
||||
.goods-image {
|
||||
display: flex;
|
||||
width: 130rpx;
|
||||
height: 130rpx;
|
||||
margin-right: 15rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.goods-name {
|
||||
display: flex;
|
||||
font-size: 35rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 30rpx;
|
||||
color: #999999;
|
||||
margin-left: 10rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.goods-price {
|
||||
display: flex;
|
||||
font-size: 30rpx;
|
||||
margin-right: 10rpx;
|
||||
justify-content: flex-end;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.count-change-view {
|
||||
.count-image {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 54rpx;
|
||||
height: 54rpx;
|
||||
background: #FBFBFB;
|
||||
|
||||
image {
|
||||
width: 15rpx;
|
||||
height: 2rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.count-image:nth-of-type(2) image {
|
||||
width: 17rpx;
|
||||
height: 17rpx;
|
||||
}
|
||||
|
||||
text {
|
||||
display: flex;
|
||||
width: 54rpx;
|
||||
height: 54rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 400;
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
background: #F2F2F2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-view {
|
||||
background: #FFFFFF;
|
||||
padding: 20rpx 30rpx 78rpx 33rpx;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
|
||||
sqb-pay {
|
||||
flex: 1;
|
||||
|
||||
.confirm-button {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
font-weight: bold;
|
||||
width: 100%;
|
||||
font-size: 30rpx;
|
||||
height: 80rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #F32B2B;
|
||||
color: #FFFFFF;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@@ -10,29 +10,78 @@
|
||||
微信登录
|
||||
</button>
|
||||
<view class='hint'>
|
||||
登录代表同意
|
||||
<text class='link' @click.stop='openPrivacy'>
|
||||
《小程序隐私保护协议》
|
||||
<image @click.stop='bindCheck'
|
||||
:src='isAgreePrivacy?("/static/images/ic_checked_green.png"):("/static/images/ic_checked_gray.png")' />
|
||||
|
||||
<text @click.stop='bindCheck'>请先阅读并同意
|
||||
<text class='link' @click.stop='openPrivacy'>
|
||||
《小程序隐私保护协议》
|
||||
</text>
|
||||
并授权使用您的账号信息(如昵称、头像、收获地址)以便您统一管理
|
||||
</text>
|
||||
并授权使用您的账号信息(如昵称、头像、收获地址)以便您统一管理
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { getCompanyList } from '@/api/company';
|
||||
import { useUserStore } from '@/store';
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import { getCompanyId, getOpenId, goPath, showToast } from '@/utils';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
const isAgreePrivacy = ref(false);
|
||||
|
||||
function wechatLogin() {
|
||||
if(!isAgreePrivacy.value) {
|
||||
showToast('请先阅读并同意小程序隐私保护协议');
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showLoading();
|
||||
userStore.authLogin().then(() => {
|
||||
userStore.login().then(async () => {
|
||||
const maOpenId = getOpenId() || userInfo.value?.maOpenId;
|
||||
const data = await getCompanyList(maOpenId);
|
||||
const companyList = data.map((item: any) => item.company);
|
||||
uni.hideLoading();
|
||||
uni.reLaunch({ url: '/pages/home/index' });
|
||||
|
||||
//登录成功先判断当前公司有没有注册过
|
||||
let index = companyList.findIndex((res: {
|
||||
id: string
|
||||
}) => res.id === (getApp()?.globalData?.shareCompanyId || getCompanyId()));
|
||||
if(index < 0) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '当前店铺还未注册,请先注册',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm) {
|
||||
goPath('/pages/common/register/index');
|
||||
} else {
|
||||
goPath('/pages/home/index');
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(getApp()?.globalData && getApp()?.globalData?.sharePath) {
|
||||
uni.reLaunch({
|
||||
url: getApp()?.globalData?.sharePath,
|
||||
onSuccess: () => {
|
||||
getApp().globalData!.sharePath = '';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.reLaunch({ url: '/pages/home/index' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const bindCheck = () => {
|
||||
isAgreePrivacy.value = !isAgreePrivacy.value;
|
||||
};
|
||||
|
||||
const openPrivacy = () => {
|
||||
wx.openPrivacyContract({
|
||||
success: () => {
|
||||
@@ -43,6 +92,7 @@ const openPrivacy = () => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
@@ -81,14 +131,23 @@ const openPrivacy = () => {
|
||||
}
|
||||
|
||||
.hint {
|
||||
display: inline-block;
|
||||
padding: 20rpx 50rpx;
|
||||
font-size: 25rpx;
|
||||
color: $u-tips-color;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
align-items: center;
|
||||
bottom: 50rpx;
|
||||
|
||||
.link {
|
||||
color: $u-warning;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
margin-right: 10rpx;
|
||||
margin-bottom: -5rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -1,144 +1,221 @@
|
||||
<template>
|
||||
<view class='content'>
|
||||
<image class='bg-image' :src='assetsUrl("bg_register.png")' />
|
||||
<view class='card-view'>
|
||||
<view class='mobile-view c-flex-row'>
|
||||
<image :src='assetsUrl("ic_register_mobile.png")' />
|
||||
<input placeholder='请输入手机号' inputmode='number' maxlength='11' />
|
||||
</view>
|
||||
|
||||
<view class='captcha-view c-flex-row'>
|
||||
<view class='c-flex-row'>
|
||||
<image :src='assetsUrl("ic_register_captcha.png")' />
|
||||
<input placeholder='请输入验证码' inputmode='number' maxlength='6' />
|
||||
</view>
|
||||
<text @click.stop='startCountdown'>{{ countdown }}</text>
|
||||
</view>
|
||||
|
||||
<text class='btn_register' @click.stop='register'>注册领券</text>
|
||||
<view class='c-flex-column avatar-container'>
|
||||
<image class='avatar' :src='avatarUrl' />
|
||||
<button class='avatar-button' open-type='chooseAvatar' @chooseavatar='chooseAvatar' />
|
||||
</view>
|
||||
<view class='c-flex-row' style='margin-top: 60rpx'>
|
||||
<label class='row-title'>姓名</label>
|
||||
<input class='row-value' type='nickname' placeholder='请输入手机号' v-model='nickName' />
|
||||
</view>
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row'>
|
||||
<label class='row-title'>手机号</label>
|
||||
<input class='row-value' placeholder='请输入手机号' type='text' v-model='telephone' />
|
||||
<button class='primary-button authorize-button' open-type='getPhoneNumber' @getphonenumber='getPhoneNumber'>
|
||||
获取手机号
|
||||
</button>
|
||||
</view>
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row'>
|
||||
<label class='row-title'>生日</label>
|
||||
<picker mode='date' @change='changeDate'>
|
||||
<text class='row-value'>{{ dayjs(birthday).format('YYYY-MM-DD') || '请选择生日' }}</text>
|
||||
</picker>
|
||||
</view>
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row'>
|
||||
<label class='row-title'>性别</label>
|
||||
<view class='c-flex-row' @click.stop='changeGender(0)'>
|
||||
<image class='gender-image'
|
||||
:src='assetsUrl(gender==="男"?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
|
||||
<text class='gender-text'>男</text>
|
||||
</view>
|
||||
<view class='c-flex-row' @click.stop='changeGender(1)'>
|
||||
<image class='gender-image'
|
||||
:src='assetsUrl(gender==="女"?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
|
||||
<text class='gender-text'>女</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style='height: 100rpx' />
|
||||
<button class='primary-button submit-button' @click='save'>确定</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { ref } from 'vue';
|
||||
import { getTelephone } from '@/api/user';
|
||||
import { useUserStore } from '@/store';
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import { getRegisterStoreId, getSessionKey, showToast } from '@/utils';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const countdown = ref('获取验证码');
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
|
||||
onLoad((e) => {
|
||||
const birthday = ref(userInfo.value.birthday || dayjs().format('YYYY-MM-DD'));
|
||||
const nickName = ref(userInfo.value.nickName);
|
||||
const gender = ref(userInfo.value.gender);
|
||||
const telephone = ref(userInfo.value.telephone);
|
||||
const avatarUrl = ref(userInfo.value.image);
|
||||
|
||||
});
|
||||
const chooseAvatar = (e: any) => {
|
||||
uni.showLoading();
|
||||
uni.uploadFile({
|
||||
url: import.meta.env.VITE_APP_BASE_API + '/wc/wechat/uploadImage',
|
||||
filePath: e.detail.avatarUrl,
|
||||
name: 'fileName',
|
||||
header: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
success: (res: any) => {
|
||||
avatarUrl.value = JSON.parse(res.data).data;
|
||||
},
|
||||
error: (err: any) => {
|
||||
showToast('上传失败');
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const startCountdown = () => {
|
||||
if(countdown.value !== '获取验证码') {
|
||||
const getPhoneNumber = (e: any) => {
|
||||
if(e.detail.errMsg === 'getPhoneNumber:ok') {
|
||||
uni.login({
|
||||
success: res => {
|
||||
getTelephone({
|
||||
sessionKey: getSessionKey(),
|
||||
code: res.code,
|
||||
iv: e.detail.iv,
|
||||
encryptedData: e.detail.encryptedData
|
||||
}).then(response => {
|
||||
if(response.phoneNumber) {
|
||||
telephone.value = response.phoneNumber;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const changeDate = (e: any) => {
|
||||
birthday.value = e.detail.value;
|
||||
};
|
||||
|
||||
const changeGender = (index: number) => {
|
||||
gender.value = index === 0 ? '男' : '女';
|
||||
};
|
||||
|
||||
const save = async () => {
|
||||
if(!getRegisterStoreId()) {
|
||||
showToast('请从公众号消息窗口点击店名打开小程序');
|
||||
return;
|
||||
}
|
||||
let time = 120;
|
||||
let interval = setInterval(() => {
|
||||
time--;
|
||||
countdown.value = `${time}s 重新获取`;
|
||||
if(time == 0) {
|
||||
clearInterval(interval);
|
||||
countdown.value = '获取验证码';
|
||||
|
||||
if(!telephone.value) {
|
||||
showToast('请输入手机号');
|
||||
return;
|
||||
}
|
||||
|
||||
await uni.showLoading();
|
||||
const registerForm = {
|
||||
image: avatarUrl.value,
|
||||
avatarUrl: avatarUrl.value,
|
||||
nickName: nickName.value,
|
||||
telephone: telephone.value,
|
||||
birthday: dayjs(birthday.value).isValid() ? dayjs(birthday.value).format('YYYY-MM-DD HH:mm:ss') : dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
gender: gender.value
|
||||
};
|
||||
|
||||
getApp().globalData?.logger.info('register params: ', registerForm);
|
||||
const result = await userStore.register(registerForm);
|
||||
getApp().globalData?.logger.info('register params: ', registerForm);
|
||||
if(result) {
|
||||
showToast('注册成功');
|
||||
if(getApp()?.globalData && getApp()?.globalData?.sharePath) {
|
||||
uni.reLaunch({
|
||||
url: getApp()?.globalData?.sharePath,
|
||||
onSuccess: () => {
|
||||
getApp().globalData!.sharePath = '';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await uni.reLaunch({
|
||||
url: '/pages/home/index'
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
uni.hideLoading();
|
||||
};
|
||||
|
||||
const register = () => {
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.content {
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
}
|
||||
display: flex;
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
|
||||
.bg-image {
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.card-view {
|
||||
background: #FFFFFF;
|
||||
border-radius: 10rpx;
|
||||
margin: 0 50rpx;
|
||||
padding: 40rpx;
|
||||
top: 600rpx;
|
||||
position: relative;
|
||||
|
||||
.mobile-view {
|
||||
border-radius: 10rpx;
|
||||
border: 1rpx solid #D8D8D8;
|
||||
padding-left: 28rpx;
|
||||
|
||||
image {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
margin-left: 26rpx;
|
||||
}
|
||||
.divider {
|
||||
margin: 30rpx 5rpx;
|
||||
}
|
||||
|
||||
.captcha-view {
|
||||
margin-top: 20rpx;
|
||||
|
||||
.c-flex-row {
|
||||
border-radius: 10rpx;
|
||||
border: 1rpx solid #D8D8D8;
|
||||
padding-left: 28rpx;
|
||||
flex: 1;
|
||||
|
||||
image {
|
||||
width: 33rpx;
|
||||
height: 26rpx;
|
||||
}
|
||||
|
||||
input {
|
||||
height: 80rpx;
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
margin-left: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
text {
|
||||
display: flex;
|
||||
height: 80rpx;
|
||||
background: #FFD436;
|
||||
border-radius: 10rpx;
|
||||
margin-left: 12rpx;
|
||||
padding: 0 15rpx;
|
||||
font-size: 28rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
.btn_register {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 90rpx;
|
||||
background: #F53636;
|
||||
border-radius: 10rpx;
|
||||
font-weight: 400;
|
||||
.row-title {
|
||||
font-size: 30rpx;
|
||||
color: #FFFFFF;
|
||||
margin-top: 46rpx;
|
||||
color: #666666;
|
||||
width: 150rpx;
|
||||
}
|
||||
|
||||
.row-value {
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
.avatar-container {
|
||||
align-items: center;
|
||||
margin-top: 20rpx;
|
||||
position: relative;
|
||||
|
||||
.avatar {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
border-radius: 10rpx;
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.avatar-button {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
background-color: transparent;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.authorize-button {
|
||||
width: auto;
|
||||
font-size: 20rpx;
|
||||
min-width: auto;
|
||||
height: 50rpx;
|
||||
}
|
||||
|
||||
.gender-image {
|
||||
width: 37rpx;
|
||||
height: 37rpx;
|
||||
}
|
||||
|
||||
.gender-text {
|
||||
width: 80rpx;
|
||||
color: #333333;
|
||||
font-size: 30rpx;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.submit-button {
|
||||
display: flex;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
228
src/pages/common/register/reward.vue
Normal file
228
src/pages/common/register/reward.vue
Normal file
@@ -0,0 +1,228 @@
|
||||
<template>
|
||||
<view class='content'>
|
||||
<image class='bg-image' :src='assetsUrl("bg_register.png")' />
|
||||
|
||||
<image :src='assetsUrl("ic_register_gift_text.png")'
|
||||
style='align-self: center;position: relative;width: 356rpx;height: 124rpx;margin-top: 70rpx' />
|
||||
<view class='card-view'>
|
||||
<view class='mobile-view c-flex-row' style='display: none'>
|
||||
<image :src='assetsUrl("ic_register_mobile.png")' />
|
||||
<input placeholder='请输入手机号' inputmode='number' maxLength='11' />
|
||||
</view>
|
||||
|
||||
<view class='captcha-view c-flex-row' style='display: none'>
|
||||
<view class='c-flex-row'>
|
||||
<image :src='assetsUrl("ic_register_captcha.png")' />
|
||||
<input placeholder='请输入验证码' inputmode='number' maxLength='6' />
|
||||
</view>
|
||||
<text @click.stop='startCountdown'>{{ countdown }}</text>
|
||||
</view>
|
||||
|
||||
<text class='btn_register' style='display: none' @click.stop='register'>注册领券</text>
|
||||
|
||||
<image :src='companyConfigInfo.regqrcode||defaultImage' :show-menu-by-longpress='true' mode='aspectFill'
|
||||
style='width: 439rpx;height: 439rpx;align-self: center' />
|
||||
<text style='font-size: 26rpx;
|
||||
margin-top: 10rpx;
|
||||
align-self: center;color: #666666;'>长按扫码注册
|
||||
</text>
|
||||
|
||||
<template v-if='couponBean&&couponBean.status==0'>
|
||||
<view class='divider' />
|
||||
<view class='coupon c-flex-column' @click.stop='goPath("/pages/mine/subs/coupon/index")'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='coupon-name'>{{ couponBean.title }}</text>
|
||||
<image :src='assetsUrl("ic_arrow_right_gray.png")' />
|
||||
</view>
|
||||
<text class='expired-time'>
|
||||
有效期至{{ dayjs(Date.now()).add(couponBean.triggerEndDay, 'day').format('YYYY.MM.DD') }}
|
||||
</text>
|
||||
</view>
|
||||
<view class='divider' />
|
||||
|
||||
<text style='font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;margin-top: 20rpx'>福利详情
|
||||
</text>
|
||||
<text style='font-size: 28rpx;
|
||||
color: #333333;margin-top: 14rpx'>1.优惠金额{{ couponBean.reduce }}元\n
|
||||
2.满{{ couponBean.threshold }}减{{ couponBean.reduce }}\n
|
||||
3.赠送{{ couponBean.publicNum }}张
|
||||
</text>
|
||||
</template>
|
||||
<template v-else>
|
||||
<text style='font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;margin-top: 20rpx'>
|
||||
微信扫一扫领取会员卡
|
||||
</text>
|
||||
<text style='font-size: 28rpx;
|
||||
color: #333333;margin-top: 14rpx'>
|
||||
1、及时接受消费小票\n
|
||||
2、随时查询消费记录\n
|
||||
3、及时接收优惠信息
|
||||
</text>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import { useUserStore } from '@/store';
|
||||
import { goPath } from '@/utils';
|
||||
import { getRegisterCoupon } from '@/api/user';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { companyConfigInfo } = storeToRefs(userStore);
|
||||
|
||||
const countdown = ref('获取验证码');
|
||||
const couponBean = ref();
|
||||
|
||||
onLoad(async (e) => {
|
||||
couponBean.value = await getRegisterCoupon();
|
||||
});
|
||||
|
||||
const startCountdown = () => {
|
||||
if(countdown.value !== '获取验证码') {
|
||||
return;
|
||||
}
|
||||
let time = 120;
|
||||
let interval = setInterval(() => {
|
||||
time--;
|
||||
countdown.value = `${time}s 重新获取`;
|
||||
if(time == 0) {
|
||||
clearInterval(interval);
|
||||
countdown.value = '获取验证码';
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const register = () => {
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.content {
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.bg-image {
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.card-view {
|
||||
background: #FFFFFF;
|
||||
border-radius: 10rpx;
|
||||
margin: 0 40rpx;
|
||||
padding: 50rpx;
|
||||
top: 150rpx;
|
||||
position: relative;
|
||||
|
||||
.mobile-view {
|
||||
border-radius: 10rpx;
|
||||
border: 1rpx solid #D8D8D8;
|
||||
padding-left: 28rpx;
|
||||
|
||||
image {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
}
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
margin-left: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.captcha-view {
|
||||
margin-top: 20rpx;
|
||||
|
||||
.c-flex-row {
|
||||
border-radius: 10rpx;
|
||||
border: 1rpx solid #D8D8D8;
|
||||
padding-left: 28rpx;
|
||||
flex: 1;
|
||||
|
||||
image {
|
||||
width: 33rpx;
|
||||
height: 26rpx;
|
||||
}
|
||||
|
||||
input {
|
||||
height: 80rpx;
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
margin-left: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
text {
|
||||
display: flex;
|
||||
height: 80rpx;
|
||||
background: #FFD436;
|
||||
border-radius: 10rpx;
|
||||
margin-left: 12rpx;
|
||||
padding: 0 15rpx;
|
||||
font-size: 28rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
.btn_register {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 90rpx;
|
||||
background: #F53636;
|
||||
border-radius: 10rpx;
|
||||
font-weight: 400;
|
||||
font-size: 30rpx;
|
||||
color: #FFFFFF;
|
||||
margin-top: 46rpx;
|
||||
}
|
||||
|
||||
.divider {
|
||||
border-bottom-style: dashed;
|
||||
border-color: #E98585;
|
||||
border-width: 0.2rpx;
|
||||
margin-top: 34rpx
|
||||
}
|
||||
|
||||
.coupon {
|
||||
margin-top: 30rpx;
|
||||
|
||||
.coupon-name {
|
||||
display: flex;
|
||||
font-size: 36rpx;
|
||||
color: #D95554;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 13rpx;
|
||||
height: 24rpx;
|
||||
}
|
||||
|
||||
.expired-time {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
margin-top: 2rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<web-view class="h-full" :src="url" />
|
||||
<web-view class='h-full' :src='url' />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
<script setup lang='ts'>
|
||||
const url = ref<string>('');
|
||||
|
||||
onLoad((params: any) => {
|
||||
if (params.url)
|
||||
url.value = params.url;
|
||||
if(params.url)
|
||||
url.value = decodeURIComponent(params.url);
|
||||
});
|
||||
</script>
|
||||
|
52
src/pages/coupons/ticketsBuy/ticketsBuy.vue
Normal file
52
src/pages/coupons/ticketsBuy/ticketsBuy.vue
Normal file
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
|
||||
import { getStoreId } from '@/api/company';
|
||||
import { isLogin, setCompanyId, setRegisterStoreId } from '@/utils';
|
||||
|
||||
onLoad(async (options) => {
|
||||
getApp().globalData?.logger?.info('ticketsBuy share options: ', options);
|
||||
|
||||
let couponId = options?.couponsId;
|
||||
if(couponId) {
|
||||
const path = `/pages/common/groupbuy/detail?couponId=${couponId}`;
|
||||
if(!isLogin() && getApp()?.globalData) {
|
||||
getApp().globalData!.sharePath = path;
|
||||
}
|
||||
|
||||
if(options?.companyId && options?.creatorId) {
|
||||
const storeId = await getStoreId({
|
||||
companyid: options?.companyId,
|
||||
deviceid: options?.creatorId
|
||||
});
|
||||
setCompanyId(options?.companyId);
|
||||
if(storeId) {
|
||||
setRegisterStoreId(storeId);
|
||||
if(getApp()?.globalData) {
|
||||
getApp().globalData!.shareCompanyId = options?.companyId;
|
||||
getApp().globalData!.shareStoreId = storeId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: path
|
||||
});
|
||||
}, 300);
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/index'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
|
||||
</style>
|
@@ -14,15 +14,15 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='user-info-card' @click.stop='goPath("/pages/mine/index")'>
|
||||
<image class='user-avatar' :src='userInfo.image||defaultAvatar' mode='aspectFill' />
|
||||
<text class='user-name primary-text-color'>{{ userInfo?.nickName || '未登录' }}</text>
|
||||
<view class='integral-view primary-text-color' @click.stop='goPath("/pages/mine/subs/integral/index")'>
|
||||
<view class='user-info-card' @click.stop='goPath("/pages/mine/index",true)'>
|
||||
<image class='user-avatar' :src='userInfo?.image||defaultAvatar' mode='aspectFill' />
|
||||
<text class='user-name primary-text-color'>{{ userInfo?.nickName || '点击注册会员' }}</text>
|
||||
<view class='integral-view primary-text-color' @click.stop='goPath("/pages/mine/subs/integral/index",true)'>
|
||||
<text>{{ userInfo?.integration || 0 }}</text>
|
||||
<text>积分</text>
|
||||
</view>
|
||||
<view class='divider' style='height: 83rpx' />
|
||||
<view class='balance-view' @click.stop='goPath("/pages/mine/subs/recharge/index")'>
|
||||
<view class='balance-view' @click.stop='goPath("/pages/mine/subs/recharge/index",true)'>
|
||||
<text class='accent-text-color'>{{ userInfo?.balance || 0 }}</text>
|
||||
<text>余额(元)</text>
|
||||
</view>
|
||||
@@ -33,13 +33,13 @@
|
||||
</view>
|
||||
|
||||
<view class='menu-view'>
|
||||
<view @click.stop='goPath("/pages/mine/subs/recharge/index")'>
|
||||
<image :src='assetsUrl("ic_member_card.png")' style='width: 108rpx;height: 72rpx;padding: 11rpx 0' />
|
||||
<view @click.stop='goPath("/pages/mine/subs/recharge/index",true)'>
|
||||
<image :src='assetsUrl("ic_member_card2.png")' style='width: 108rpx;height: 72rpx;padding: 11rpx 0' />
|
||||
<text>会员充值</text>
|
||||
</view>
|
||||
<view class='divider' style='margin: 0;height: 153rpx' />
|
||||
<view @click.stop='goPath("/pages/mine/subs/coupon/index")'>
|
||||
<image :src='assetsUrl("ic_coupon.png")' style='width: 108rpx;height: 95rpx' />
|
||||
<view @click.stop='goPath("/pages/mine/subs/coupon/index",true)'>
|
||||
<image :src='assetsUrl("ic_coupon2.png")' style='width: 108rpx;height: 95rpx' />
|
||||
<text>优惠券</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -57,22 +57,26 @@
|
||||
|
||||
<view class='bottom-banner-view'>
|
||||
<swiper :indicator-dots='true' :autoplay='true' :interval='3000' :duration='1000'>
|
||||
<swiper-item v-for='(item, index) in companyConfigInfo.bannerhot' :key='index'>
|
||||
<swiper-item v-for='(item, index) in companyConfigInfo?.bannerhot' :key='index'>
|
||||
<image :src='item.src' mode='aspectFill' />
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<CompanyDialog ref='companyDialogRef' :companyList='companyList' />
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import CompanyDialog from '@/components/company-dialog.vue';
|
||||
import { getCompanyList } from '@/api/company';
|
||||
import { useUserStore } from '@/store';
|
||||
import { assetsUrl, defaultAvatar, defaultImage } from '@/utils/assets';
|
||||
import { getCompanyId, goPath, isLogin } from '@/utils';
|
||||
import { getOpenId, goPath, isLogin } from '@/utils';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { UserBean } from '@/store/modules/user/types';
|
||||
|
||||
const companyDialogRef = ref();
|
||||
const userStore = useUserStore();
|
||||
const { userInfo, companyConfigInfo } = storeToRefs(userStore);
|
||||
const currentBannerIndex = ref(0);
|
||||
@@ -80,20 +84,27 @@ const currentBannerIndex = ref(0);
|
||||
const submenuList = [
|
||||
{
|
||||
title: '注册有礼',
|
||||
icon: assetsUrl('ic_register_gift.png'),
|
||||
path: '/pages/common/register/index'
|
||||
icon: assetsUrl('ic_register_gift2.png'),
|
||||
path: '/pages/common/register/reward'
|
||||
// path: '/pages/common/register/index'
|
||||
// path: '/pages/common/groupbuy/detail?id=1800768359753097217'
|
||||
// path: '/pages/common/groupbuy/detail?shareId=1797548579864748033'
|
||||
// path: '/pages/coupons/ticketsBuy/ticketsBuy?couponsId=1800381015472513026'
|
||||
//1799264392762138626
|
||||
},
|
||||
{
|
||||
title: '团购秒杀',
|
||||
icon: assetsUrl('ic_groupbuy.png'),
|
||||
icon: assetsUrl('ic_groupbuy2.png'),
|
||||
path: '/pages/common/groupbuy/index'
|
||||
},
|
||||
{
|
||||
title: '入群有礼',
|
||||
icon: assetsUrl('ic_group_gift.png'),
|
||||
icon: assetsUrl('ic_group_gift2.png'),
|
||||
path: '/pages/home/subs/group/join'
|
||||
}
|
||||
];
|
||||
const companyList = ref([]);
|
||||
const userList = ref<UserBean[]>([]);
|
||||
|
||||
onMounted(() => {
|
||||
wx.getPrivacySetting({
|
||||
@@ -120,31 +131,108 @@ onLoad((e) => {
|
||||
|
||||
onShow(async () => {
|
||||
if(isLogin()) {
|
||||
if(userInfo.value.maOpenId) {
|
||||
if(getCompanyId() === '') {
|
||||
switchCompany();
|
||||
}
|
||||
} else {
|
||||
await userStore.getProfile();
|
||||
}
|
||||
// userStore.getProfile();
|
||||
fetchCompanyList();
|
||||
} else {
|
||||
// setToken('42ae187265fb4688804fd294cbcf99f1')
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您还未登录,请先登录',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm) {
|
||||
goPath('/pages/common/login/index');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const switchCompany = () => {
|
||||
getCompanyList(userInfo.value.maOpenId).then(res => {
|
||||
const companyList = res.map((res: { company: any }) => res.company);
|
||||
const userList = res.map((res: { user: any }) => res.user);
|
||||
uni.showActionSheet({
|
||||
itemList: companyList.map((res: { companyName: string }) => res.companyName),
|
||||
success: (res) => {
|
||||
userStore.setUserInfo(userList[res.tapIndex]);
|
||||
}
|
||||
fetchCompanyList((companyList: any[], userList: any[]) => {
|
||||
companyDialogRef.value.show(getApp().globalData?.companyId, (index: number) => {
|
||||
userStore.setUserInfo(userList[index]);
|
||||
userStore.setCompanyInfo(companyList[index]);
|
||||
|
||||
// avatarModifyRemind();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function avatarModifyRemind() {
|
||||
setTimeout(() => {
|
||||
if(userInfo.value.image === defaultAvatar) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '为了提供更优质的个性化服务,请先修改头像',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm) {
|
||||
goPath('/pages/mine/subs/profile/index');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
const fetchCompanyList = (fn: any = undefined) => {
|
||||
const maOpenId = getOpenId() || userInfo.value?.maOpenId || (userList.value.filter((res: UserBean) => res?.maOpenId !== '')[0]?.maOpenId);
|
||||
getCompanyList(maOpenId).then(res => {
|
||||
companyList.value = res.map((res: { company: any }) => res.company);
|
||||
userList.value = res.map((res: { user: any }) => res.user);
|
||||
|
||||
if(companyList.value.length === 0) {
|
||||
showRegisterModal();
|
||||
return;
|
||||
}
|
||||
|
||||
if(fn != undefined && fn instanceof Function) {
|
||||
fn(companyList.value, userList.value);
|
||||
} else {
|
||||
let index = companyList.value.findIndex((res: { id: string }) => res.id === getApp()?.globalData?.companyId);
|
||||
//未在当前公司下注册
|
||||
if(index < 0) {
|
||||
showRegisterModal();
|
||||
return;
|
||||
}
|
||||
|
||||
//分享过来的公司id和店铺id
|
||||
if(getApp()?.globalData?.shareCompanyId && getApp()?.globalData?.shareStoreId) {
|
||||
index = companyList.value.findIndex((res: { id: string }) => res.id === getApp().globalData?.shareCompanyId);
|
||||
if(index < 0) {
|
||||
showRegisterModal();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
userStore.setUserInfo(userList.value[index]);
|
||||
userStore.setCompanyInfo(companyList.value[index]);
|
||||
// avatarModifyRemind();
|
||||
|
||||
//首页选中处理后清空分享数据,避免再次选中
|
||||
if(getApp()?.globalData?.shareCompanyId && getApp()?.globalData?.shareStoreId) {
|
||||
getApp().globalData!.shareCompanyI = '';
|
||||
getApp().globalData!.shareStoreId = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const showRegisterModal = () => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '当前店铺还未注册,请先注册',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm) {
|
||||
goPath('/pages/common/register/index');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const swiperChange = (e: any) => {
|
||||
currentBannerIndex.value = e.detail.current;
|
||||
};
|
||||
@@ -219,6 +307,10 @@ const swiperChange = (e: any) => {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
margin-left: 16rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.integral-view {
|
||||
|
@@ -6,7 +6,7 @@
|
||||
1.长按识别下方二维码,添加【店铺福利群】
|
||||
</text>
|
||||
<view class='divider' style='margin-top: 28rpx' />
|
||||
<image :src=' companyConfigInfo.regqrcode' show-menu-by-longpress />
|
||||
<image :src=' companyConfigInfo.groupqrcode||defaultImage' show-menu-by-longpress />
|
||||
<text class='step-title'>
|
||||
2.识别【店铺福利群】发您的二维码,即可入群
|
||||
</text>
|
||||
@@ -16,6 +16,7 @@
|
||||
<script lang='ts' setup>
|
||||
|
||||
import { useUserStore } from '@/store';
|
||||
import { defaultImage } from '@/utils/assets';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { companyConfigInfo } = storeToRefs(userStore);
|
||||
|
@@ -3,10 +3,51 @@
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
onMounted(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/index'
|
||||
});
|
||||
|
||||
import { isLogin, setCompanyId, setRegisterStoreId } from '@/utils';
|
||||
import { getStoreId } from '@/api/company';
|
||||
|
||||
onLoad(async (options) => {
|
||||
getApp().globalData?.logger?.info('app share index/index options: ', options);
|
||||
|
||||
if(options?.companyId) {
|
||||
setCompanyId(options?.companyId);
|
||||
let storeId = options?.storeId || await getStoreId({
|
||||
companyid: options?.companyId,
|
||||
deviceid: options?.creatorId
|
||||
});
|
||||
|
||||
if(storeId) {
|
||||
setRegisterStoreId(storeId);
|
||||
}
|
||||
|
||||
if(getApp()?.globalData) {
|
||||
getApp().globalData!.shareCompanyId = options?.companyId;
|
||||
getApp().globalData!.shareStoreId = storeId;
|
||||
}
|
||||
}
|
||||
|
||||
let goodsShareId = '';
|
||||
if(options?.shareId) {
|
||||
goodsShareId = options?.shareId;
|
||||
}
|
||||
getApp().globalData?.logger?.info('app share index/index options: goodsShareId ', goodsShareId);
|
||||
|
||||
if(goodsShareId) {
|
||||
const path = `/pages/common/groupbuy/detail?shareId=${goodsShareId}`;
|
||||
if(!isLogin() && getApp()?.globalData) {
|
||||
getApp().globalData!.sharePath = path;
|
||||
}
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: path
|
||||
});
|
||||
}, 300);
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/index'
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<view class='search-view'>
|
||||
<view class='search-input' @click.stop='goPath("/pages/mall/subs/search/index")'>
|
||||
<image :src=' assetsUrl("ic_search.png")'></image>
|
||||
<input placeholder='输入名称、款号搜索' />
|
||||
<input placeholder='输入名称、款号搜索' :disabled='true' />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -21,17 +21,23 @@
|
||||
<view v-for='(item, index) in goodsList' :key='index' class='goods-item'
|
||||
@click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'>
|
||||
<image class='goods-image' :src='item.images||defaultImage' />
|
||||
<text class='goods-name'>{{ item.goodsName }}</text>
|
||||
<text class='goods-price'>¥{{ item.price }}</text>
|
||||
<text class='goods-name'>{{ item.goodsName || '未知' }}</text>
|
||||
<text class='goods-price'>¥{{ (item.price * userInfo.userDiscount).toFixed(2) }}
|
||||
<text v-if='userInfo.userDiscount>0&&userInfo.userDiscount<1'
|
||||
style='text-decoration: line-through;color: #999999;font-size: 25rpx'>
|
||||
¥{{ item.price }}
|
||||
</text>
|
||||
</text>
|
||||
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
|
||||
</view>
|
||||
</grid-view>
|
||||
<u-empty v-if='goodsList.length === 0' text='暂无商品数据' />
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<view class='shopping-cart' @click.stop='goPath("/pages/mall/subs/shoppingcart/index")'>
|
||||
<image :src='assetsUrl("ic_shopping_cart.png")' />
|
||||
<text v-if='shoppingCartList.length>0'>{{ shoppingCartList?.length }}</text>
|
||||
<text v-if='totalCount>0'>{{ totalCount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class='content' v-else style='align-items: center;justify-content:center;'>
|
||||
@@ -41,18 +47,19 @@
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import SkuDialog from '@/components/sku-dialog.vue';
|
||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import { goLogin, goPath, isLogin, showToast } from '@/utils';
|
||||
import { goPath, isLogin, showToast } from '@/utils';
|
||||
import { getCategoryList, getGoodsList } from '@/api/goods';
|
||||
import { CategoryBean, GoodsBean } from '@/api/goods/types';
|
||||
import useShoppingCartStore from '@/store/modules/shoppingcart';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { companyConfigInfo } = storeToRefs(userStore);
|
||||
const { userInfo, companyConfigInfo } = storeToRefs(userStore);
|
||||
const shoppingCartStore = useShoppingCartStore();
|
||||
const { shoppingCartList } = storeToRefs(shoppingCartStore);
|
||||
const { totalCount } = storeToRefs(shoppingCartStore);
|
||||
|
||||
const skuDialogRef = ref();
|
||||
const categoryList = ref<CategoryBean[]>([]);
|
||||
@@ -62,17 +69,15 @@ const currentPageNum = ref<number>(1);
|
||||
|
||||
onLoad(() => {
|
||||
if(!isLogin()) {
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('companyConfigInfo.value', companyConfigInfo.value);
|
||||
|
||||
userStore.$onAction(({ name, after }) => {
|
||||
after(() => {
|
||||
//更新用户信息
|
||||
if(name === 'setUserInfo') {
|
||||
fetchCategoryList();
|
||||
shoppingCartStore.resetData();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -80,9 +85,26 @@ onLoad(() => {
|
||||
fetchCategoryList();
|
||||
});
|
||||
|
||||
onShareAppMessage((e) => {
|
||||
return {
|
||||
title: 'VIP顾客中心',
|
||||
path: '/pages/mall/index'
|
||||
};
|
||||
});
|
||||
|
||||
onShareTimeline((e) => {
|
||||
return {
|
||||
title: 'VIP顾客中心',
|
||||
path: '/pages/mall/index'
|
||||
};
|
||||
});
|
||||
const fetchCategoryList = async () => {
|
||||
if(companyConfigInfo.value.mallopen == 1) {
|
||||
categoryList.value = await getCategoryList();
|
||||
const list = await getCategoryList();
|
||||
list.unshift({ typeName: '上新精选', typeId: '2' });
|
||||
list.unshift({ typeName: '热销商品', typeId: '1' });
|
||||
list.unshift({ typeName: '全部分类', typeId: '0' });
|
||||
categoryList.value = list;
|
||||
await changeCategory(0);
|
||||
}
|
||||
};
|
||||
@@ -94,13 +116,27 @@ const changeCategory = async (index: number) => {
|
||||
|
||||
const fetchGoodsList = async (refresh: boolean = true) => {
|
||||
currentPageNum.value = refresh ? 1 : currentPageNum.value + 1;
|
||||
|
||||
let typeId = [categoryList.value[categorySelectedIndex.value].typeId];
|
||||
let sort = undefined;
|
||||
if(typeId[0] === '0') {
|
||||
typeId = [];
|
||||
sort = undefined;
|
||||
} else if(typeId[0] === '1') {
|
||||
typeId = [];
|
||||
sort = 'good_num DESC';
|
||||
} else if(typeId[0] === '2') {
|
||||
typeId = [];
|
||||
sort = 'update_time DESC';
|
||||
}
|
||||
const { rows } = await getGoodsList({
|
||||
page: {
|
||||
pageNum: currentPageNum.value,
|
||||
pageSize: 30,
|
||||
bean: {
|
||||
keyword: '',
|
||||
typeIds: [categoryList.value[categorySelectedIndex.value].typeId]
|
||||
typeIds: typeId,
|
||||
sort: sort
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -109,6 +145,10 @@ const fetchGoodsList = async (refresh: boolean = true) => {
|
||||
} else {
|
||||
goodsList.value = goodsList.value.concat(rows);
|
||||
}
|
||||
|
||||
goodsList.value.forEach(e => {
|
||||
e.price = userStore.getRealGoodsPrice(e.price, e.priceExt);
|
||||
});
|
||||
};
|
||||
|
||||
const loadMore = () => {
|
||||
@@ -127,7 +167,16 @@ const getRandomFloatInRange = (a: number, b: number) => {
|
||||
|
||||
const addShoppingCart = (goodsBean: GoodsBean) => {
|
||||
skuDialogRef.value.show(goodsBean.goodsId, (e: GoodsBean) => {
|
||||
shoppingCartStore.save(e);
|
||||
//重新选择sku后判断当前购物中是否存在相同sku的商品
|
||||
const existsIndex = shoppingCartStore.getSameGoodsIndex(e?.id || '', e.checkedStock.colorId, e.checkedStock.sizeId);
|
||||
//不存在则更新当前商品sku
|
||||
if(existsIndex < 0) {
|
||||
shoppingCartStore.save(e);
|
||||
}
|
||||
//如果已存在,则更新已存在商品数量,并删除当前商品
|
||||
else {
|
||||
shoppingCartStore.updateCount(existsIndex, e.checkedStock.count);
|
||||
}
|
||||
showToast('添加购物车成功');
|
||||
});
|
||||
};
|
||||
@@ -171,7 +220,7 @@ const addShoppingCart = (goodsBean: GoodsBean) => {
|
||||
.category-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 210rpx;
|
||||
width: 280rpx;
|
||||
height: 100vh;
|
||||
|
||||
.category-item {
|
||||
|
@@ -38,7 +38,7 @@ const coupons = ref<CouponBean[]>([]);
|
||||
|
||||
const fetchData = async (status: number) => {
|
||||
const { list } = await getCouponList({
|
||||
companyId: getCompanyId(),
|
||||
companyId: getApp()?.globalData?.companyId,
|
||||
memberId: userInfo.value?.id,
|
||||
status: status,
|
||||
pageNum: 1,
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<view class='swiper-container'>
|
||||
<swiper class='swiper' :interval='1500' :duration='1000' @change='swiperChange'>
|
||||
<swiper-item v-for='(item,index) in [goodsBean?.images]' :key='index'>
|
||||
<image :src='item||defaultImage' />
|
||||
<image :src='item||defaultImage' mode='aspectFill' />
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class='indicator' style='display: none'>
|
||||
@@ -14,13 +14,19 @@
|
||||
|
||||
<view class='goods-info-view c-flex-column' style='margin-right: 10rpx'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='goods-price accent-text-color'>{{ goodsBean?.price || 0 }}</text>
|
||||
<text>销量{{ goodsBean?.send_num || 0 }}</text>
|
||||
<text class='goods-price accent-text-color'>
|
||||
¥{{ ((goodsBean?.price || 0) * userInfo.userDiscount).toFixed(2) }}
|
||||
<text v-if='userInfo.userDiscount>0&&userInfo.userDiscount<1'
|
||||
style='display:unset;text-decoration: line-through;font-size: 30rpx;color: #999999'>
|
||||
¥{{ goodsBean?.price || 0 }}
|
||||
</text>
|
||||
</text>
|
||||
<text>销量{{ goodsBean?.salesCount || 0 }}</text>
|
||||
</view>
|
||||
|
||||
<view class='c-flex-row'>
|
||||
<text style='flex: 1'>{{ goodsBean?.name }}</text>
|
||||
<view class='share-button c-flex-column'>
|
||||
<text style='flex: 1'>{{ goodsBean?.name || '未知' }}</text>
|
||||
<view class='share-button'>
|
||||
<image :src='assetsUrl("ic_share.png")'></image>
|
||||
<button class='btn' plain open-type='share'>分享</button>
|
||||
</view>
|
||||
@@ -42,15 +48,19 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class='recommend-view c-flex-column' v-if='recommendList?.length>0'>
|
||||
<view class='recommend-view c-flex-column' v-if='(recommendList?.length||0)>0'>
|
||||
<text>浏览此商品的客户还浏览了</text>
|
||||
<scroll-view scroll-x>
|
||||
<view style='display: inline-block' v-for='(item, index) in recommendList'
|
||||
:key='index'>
|
||||
<view class='recommend-item c-flex-column'>
|
||||
<image :src='item.images||defaultImage' />
|
||||
<text>{{ item.goodsName }}</text>
|
||||
<text class='goods-price'>{{ item.price }}</text>
|
||||
<text>{{ item.goodsName || '未知' }}</text>
|
||||
<text class='goods-price'>{{ (item.price * userInfo.userDiscount).toFixed(2) }}
|
||||
<text v-if='userInfo.userDiscount>0&&userInfo.userDiscount<1'
|
||||
style='text-decoration: line-through;font-size: 25rpx;color: #999999'>{{ item.price }}
|
||||
</text>
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -78,7 +88,7 @@
|
||||
<view class='small-button-item'>
|
||||
<view class='shoppingcart-count' @click.stop='goPath("/pages/mall/subs/shoppingcart/index")'>
|
||||
<image :src='assetsUrl("ic_goods_shoppingcart.png")' />
|
||||
<text v-if='shoppingCartList.length>0'>{{ shoppingCartList.length }}</text>
|
||||
<text v-if='totalCount>0'>{{ totalCount }}</text>
|
||||
</view>
|
||||
<text>购物车</text>
|
||||
</view>
|
||||
@@ -100,9 +110,13 @@ import { goPath, showToast } from '@/utils';
|
||||
import { getGoodsDetail, getGoodsList } from '@/api/goods';
|
||||
import { GoodsBean } from '@/api/goods/types';
|
||||
import useShoppingCartStore from '@/store/modules/shoppingcart';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const shoppingCartStore = useShoppingCartStore();
|
||||
const { shoppingCartList } = storeToRefs(shoppingCartStore);
|
||||
const { totalCount } = storeToRefs(shoppingCartStore);
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
|
||||
const goodsBean = ref<GoodsBean>();
|
||||
const recommendList = ref<GoodsBean[]>();
|
||||
@@ -115,20 +129,31 @@ const swiperIndex = ref(0);
|
||||
onLoad(async (e: any) => {
|
||||
await uni.showLoading();
|
||||
goodsBean.value = await getGoodsDetail(e.goodsId);
|
||||
goodsBean.value.price = userStore.getRealGoodsPrice(goodsBean.value?.price, goodsBean.value?.priceExt);
|
||||
const { rows } = await getGoodsList({
|
||||
page: {
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
bean: {
|
||||
keyword: '',
|
||||
typeIds: ['1724629185362591745']
|
||||
typeIds: []
|
||||
}
|
||||
}
|
||||
});
|
||||
recommendList.value = rows;
|
||||
recommendList.value?.forEach(e => {
|
||||
e.price = userStore.getRealGoodsPrice(e.price, e.priceExt);
|
||||
});
|
||||
uni.hideLoading();
|
||||
});
|
||||
|
||||
onShareAppMessage((e) => {
|
||||
return {
|
||||
title: goodsBean.value?.name || 'VIP顾客中心',
|
||||
path: `/pages/common/groupbuy/detail?id=${goodsBean.value?.id}&companyId=${getApp().globalData?.companyId}&storeId=${getApp().globalData?.storeId}`
|
||||
};
|
||||
});
|
||||
|
||||
const getStockColorCount = computed(() => {
|
||||
const list = Array.from(new Set(goodsBean.value?.stocks?.map(item => item.colorName)))
|
||||
.map(colorName => goodsBean.value?.stocks?.find(item => item.colorName === colorName)!);
|
||||
@@ -162,7 +187,7 @@ const addShoppingCart = () => {
|
||||
const placeOrder = () => {
|
||||
showSkuDialog((e: GoodsBean) => {
|
||||
const orderBean = {
|
||||
totalPrice: e.price * e.checkedStock.count,
|
||||
totalPrice: (e.consumePrice * e.checkedStock.count).toFixed(2),
|
||||
orderGoods: [e]
|
||||
};
|
||||
goPath(`/pages/mall/subs/order/order-confirm?orderBean=${encodeURIComponent(JSON.stringify(orderBean))}`);
|
||||
@@ -215,6 +240,9 @@ const placeOrder = () => {
|
||||
padding: 20rpx 30rpx;
|
||||
|
||||
view:nth-of-type(1) {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
text:nth-of-type(1) {
|
||||
display: flex;
|
||||
font-size: 40rpx;
|
||||
@@ -224,10 +252,10 @@ const placeOrder = () => {
|
||||
}
|
||||
|
||||
.goods-price:before {
|
||||
content: "¥";
|
||||
font-size: 30rpx;
|
||||
margin-bottom: 5rpx;
|
||||
margin-right: 5rpx;
|
||||
//content: "¥";
|
||||
//font-size: 30rpx;
|
||||
//margin-bottom: 5rpx;
|
||||
//margin-right: 5rpx;
|
||||
}
|
||||
|
||||
text:nth-of-type(2) {
|
||||
@@ -246,6 +274,8 @@ const placeOrder = () => {
|
||||
}
|
||||
|
||||
.share-button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
image {
|
||||
|
@@ -42,14 +42,15 @@
|
||||
<image class='goods-image' :src='item.images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1;'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='goods-name'>{{ item.name }}</text>
|
||||
<text class='goods-name'>{{ item.name || '未知' }}</text>
|
||||
</view>
|
||||
<text style='color: #999999;margin-top: 30rpx'>
|
||||
{{ item.code }}
|
||||
</text>
|
||||
<view class='bottom-sku-view c-flex-row'>
|
||||
<text>
|
||||
{{ item.checkedStock.colorName }},{{ item.checkedStock.sizeName }} x{{ item.checkedStock.count }}
|
||||
{{ item.checkedStock.colorName || '均色' }},{{ item.checkedStock.sizeName || '均码' }}
|
||||
x{{ item.checkedStock.count }}
|
||||
</text>
|
||||
<text>¥{{ item.price }}</text>
|
||||
</view>
|
||||
@@ -124,7 +125,7 @@
|
||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import PaymentDialog from '@/components/payment-dialog.vue';
|
||||
import CouponDialog from '@/pages/mall/subs/components/coupon-dialog.vue';
|
||||
import { goPath, parseParameter, sortASCII } from '@/utils';
|
||||
import { goPath, parseParameter, showToast, sortASCII } from '@/utils';
|
||||
import { hexMD5 } from '@/utils/common/md5';
|
||||
import { getPaymentList, orderCreate, overPayment } from '@/api/order';
|
||||
import { CouponBean } from '@/api/user/types';
|
||||
@@ -159,17 +160,17 @@ const buildSqbParams = computed(() => {
|
||||
const params = sortASCII({
|
||||
client_sn: orderBean.value?.id || '',
|
||||
return_url: '/pages/common/payresult/index',
|
||||
total_amount: ((orderBean.value?.totalPrice || 0) * 100).toString(),
|
||||
terminal_sn: terminalInfo.value.terminalSn,
|
||||
subject: orderBean?.value?.orderGoods[0].name,
|
||||
subject_img: orderBean?.value?.orderGoods[0].images || '',
|
||||
merchant_name: terminalInfo.value.companyName,
|
||||
total_amount: Number(((totalPrice.value || 0) * 100).toFixed(2)),
|
||||
terminal_sn: terminalInfo.value?.terminalSn,
|
||||
subject: orderBean?.value?.orderGoods[0].name || '未知',
|
||||
subject_img: orderBean?.value?.orderGoods[0].images || 'xxx',
|
||||
merchant_name: terminalInfo.value?.companyName,
|
||||
notify_url: 'https://www.baidu.com'
|
||||
}, true);
|
||||
|
||||
return {
|
||||
...params,
|
||||
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value.terminalKey).toUpperCase()
|
||||
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value?.terminalKey).toUpperCase()
|
||||
};
|
||||
});
|
||||
|
||||
@@ -187,17 +188,30 @@ const confirmCoupon = (item: CouponBean) => {
|
||||
};
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.id, e, {
|
||||
onSuccess: () => {
|
||||
onSuccess: (options:any) => {
|
||||
console.log('pay success');
|
||||
payment();
|
||||
},
|
||||
onFailure: () => {
|
||||
console.error('pay onFailure');
|
||||
onFailure: (e:any) => {
|
||||
console.error('pay onFailure ',e);
|
||||
if(orderBean.value?.id) {
|
||||
orderBean.value.id = '';
|
||||
}
|
||||
createOrder();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const createOrder = async () => {
|
||||
if(!terminalInfo.value) {
|
||||
showToast('当前店铺未配置收款渠道,请联系商家');
|
||||
return;
|
||||
}
|
||||
//邮寄
|
||||
if(tabIndex.value == 1 && !deliveryAddress.value.addrid) {
|
||||
showToast('请选择收货地址');
|
||||
return;
|
||||
}
|
||||
const params = {
|
||||
// 'discount': 0,
|
||||
// 'freePrice': 0,
|
||||
@@ -217,7 +231,7 @@ const createOrder = async () => {
|
||||
'stockId': item.checkedStock.stockId,
|
||||
'originPrice': item.price,
|
||||
// 'consumePrice': item.price * ((userInfo.value?.levelEntity?.discount || 0) / 100),
|
||||
'consumePrice': item.price,
|
||||
'consumePrice': item.consumePrice,
|
||||
'discount': userInfo.value?.levelEntity?.discount || 0
|
||||
// 'discountOriginPrice': 0,
|
||||
// 'produceIntegral': 0,
|
||||
@@ -227,10 +241,12 @@ const createOrder = async () => {
|
||||
))
|
||||
};
|
||||
|
||||
await uni.showLoading();
|
||||
const result = await orderCreate(params);
|
||||
orderBean.value!.id = result.id;
|
||||
uni.hideLoading();
|
||||
if(orderBean.value?.id == undefined || orderBean.value?.id == '') {
|
||||
await uni.showLoading();
|
||||
const result = await orderCreate(params);
|
||||
orderBean.value!.id = result.id;
|
||||
uni.hideLoading();
|
||||
}
|
||||
|
||||
//删除购物车已存在商品
|
||||
orderBean?.value?.orderGoods?.forEach(item => {
|
||||
@@ -250,7 +266,7 @@ const payment = async () => {
|
||||
transactionPrice: orderBean?.value?.totalPrice,
|
||||
useGold: orderBean.value?.useGold || 0,
|
||||
detailBos: [{
|
||||
integralNumber: orderBean?.value?.totalPrice || 0,
|
||||
integralNumber: Math.floor(orderBean?.value?.totalPrice || 0),
|
||||
onlinePayResult: '',
|
||||
payName: '收钱吧',
|
||||
payTypeId: paymentList.find((res: any) => res.type === 'ShouQianBa')?.id,
|
||||
@@ -258,7 +274,13 @@ const payment = async () => {
|
||||
}]
|
||||
};
|
||||
await overPayment(paymentParams);
|
||||
uni.hideLoading();
|
||||
showToast('支付成功', {
|
||||
icon: 'success',
|
||||
complete: () => {
|
||||
uni.navigateBack();
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@@ -12,8 +12,12 @@
|
||||
<view v-for='(item, index) in goodsList' :key='index' class='goods-item'
|
||||
@click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'>
|
||||
<image class='goods-image' :src='item.images||defaultImage' />
|
||||
<text class='goods-name'>{{ item.goodsName }}</text>
|
||||
<text class='goods-price'>¥{{ item.price }}</text>
|
||||
<text class='goods-name'>{{ item.goodsName || '未知' }}</text>
|
||||
<text class='goods-price'>¥{{ (item.price * userInfo.userDiscount).toFixed(2) }}
|
||||
<text v-if='userInfo.userDiscount>0&&userInfo.userDiscount<1'
|
||||
style='text-decoration: line-through;color: #999999;font-size: 25rpx'>¥{{ item.price }}
|
||||
</text>
|
||||
</text>
|
||||
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
|
||||
</view>
|
||||
</grid-view>
|
||||
@@ -29,10 +33,14 @@ import { goPath } from '@/utils';
|
||||
import { getGoodsList } from '@/api/goods';
|
||||
import useShoppingCartStore from '@/store/modules/shoppingcart';
|
||||
import { GoodsBean } from '@/api/goods/types';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const skuDialogRef = ref();
|
||||
const shoppingCartStore = useShoppingCartStore();
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
|
||||
const goodsList = ref<GoodsBean[]>([]);
|
||||
|
||||
onLoad((e) => {
|
||||
@@ -46,7 +54,7 @@ const bindInput = async (e: any) => {
|
||||
pageSize: 100,
|
||||
bean: {
|
||||
keyword: e.detail.value,
|
||||
typeIds: ['1724629185362591745']
|
||||
typeIds: []
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -113,7 +121,7 @@ const addShoppingCart = (goodsBean: GoodsBean) => {
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: #333333;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-line-clamp: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-top: 10rpx;
|
||||
|
@@ -6,25 +6,30 @@
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class='card-view' v-if='shoppingCartList.length>0'>
|
||||
<view class='card-view' v-if='totalCount>0'>
|
||||
<scroll-view>
|
||||
<view class='c-flex-column' v-for='(item, index) in shoppingCartList' :key='index'>
|
||||
<view class='c-flex-row'>
|
||||
<image class='checkbox'
|
||||
:src='assetsUrl(item.checked?"ic_checkbox_active_red.png":"ic_checkbox_normal.png")'
|
||||
@click.stop='item.checked=!item.checked' />
|
||||
@click.stop='handleCheck(item)' />
|
||||
<image class='goods-image' :src='item.images||defaultImage' />
|
||||
<view class='c-flex-column'>
|
||||
<text>{{ item.name }}</text>
|
||||
<view class='c-flex-row'>
|
||||
<view class='sku-view' @click.stop='showSkuDialog(index)'>
|
||||
<text>{{ item?.checkedStock?.colorName }},{{ item?.checkedStock?.sizeName }}
|
||||
<text>{{ item?.checkedStock?.colorName||'均色' }},{{ item?.checkedStock?.sizeName||'均码' }}
|
||||
x{{ item?.checkedStock?.count }}
|
||||
</text>
|
||||
<image :src='assetsUrl("ic_arrow_down_gray.png")' />
|
||||
</view>
|
||||
</view>
|
||||
<text style='margin-top: 50rpx'>¥{{ item.price }}</text>
|
||||
<text style='margin-top: 50rpx'>
|
||||
¥{{ (item?.price * userInfo.userDiscount).toFixed(2) }}
|
||||
<text v-if='userInfo.userDiscount>0&&userInfo.userDiscount<1'
|
||||
style='text-decoration: line-through;color: #999999;font-size: 25rpx'>¥{{ item?.price }}
|
||||
</text>
|
||||
</text>
|
||||
<view class='count-change-view c-flex-row'>
|
||||
<view class='count-image' @click.stop='countChange(index,false)'>
|
||||
<image :src='assetsUrl("ic_reduce.png")' />
|
||||
@@ -39,9 +44,10 @@
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<u-empty v-else text='暂无数据' margin-top='100' />
|
||||
|
||||
<view class='bottom-view c-flex-row'>
|
||||
<view class='c-flex-row' @click.stop='checkedAll = !checkedAll'>
|
||||
<view class='c-flex-row' @click.stop='handleAllCheck'>
|
||||
<image :src='assetsUrl(checkedAll?"ic_checkbox_active.png":"ic_checkbox_normal.png")' />
|
||||
<text>全选</text>
|
||||
</view>
|
||||
@@ -50,7 +56,7 @@
|
||||
<text v-if='isEditMode' class='settlement' @click.stop='deleteShoppingCart'>删除</text>
|
||||
<view v-else class='c-flex-row'>
|
||||
<text>合计:
|
||||
<text>¥{{ totalPayPrice }}</text>
|
||||
<text>¥{{ totalPayPrice.toFixed(2) }}</text>
|
||||
</text>
|
||||
<text class='settlement' @click.stop='settlement'>结算</text>
|
||||
</view>
|
||||
@@ -67,29 +73,45 @@ import { goPath, showToast } from '@/utils';
|
||||
import { GoodsBean, StockBean } from '@/api/goods/types';
|
||||
import SkuDialog from '@/components/sku-dialog.vue';
|
||||
import { ref } from 'vue';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const isEditMode = ref(false);
|
||||
const checkedAll = ref(false);
|
||||
|
||||
const shoppingCartStore = useShoppingCartStore();
|
||||
const { shoppingCartList } = storeToRefs(shoppingCartStore);
|
||||
const { shoppingCartList, totalCount } = storeToRefs(shoppingCartStore);
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
|
||||
const skuDialogRef = ref();
|
||||
const temporaryGoodsBean = ref<GoodsBean>();
|
||||
const temporaryStockBean = ref<StockBean>();
|
||||
|
||||
watch(checkedAll, (newValue) => {
|
||||
shoppingCartList.value.forEach(res => {
|
||||
res.checked = newValue;
|
||||
});
|
||||
const totalPayPrice = computed(() => {
|
||||
return shoppingCartList.value.filter(res => res.checked).reduce((a, b) => a + b.consumePrice * b.checkedStock.count, 0) || 0;
|
||||
});
|
||||
|
||||
const totalPayPrice = computed(() => {
|
||||
return shoppingCartList.value.filter(res => res.checked).reduce((a, b) => a + b.price * b.checkedStock.count, 0);
|
||||
});
|
||||
const handleCheck = (item: any) => {
|
||||
item.checked = !item.checked;
|
||||
if(!item.checked) {
|
||||
checkedAll.value = false;
|
||||
} else {
|
||||
checkedAll.value = shoppingCartList.value.every(res => res.checked);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAllCheck = () => {
|
||||
checkedAll.value = !checkedAll.value;
|
||||
shoppingCartList.value.forEach(res => {
|
||||
res.checked = checkedAll.value;
|
||||
});
|
||||
};
|
||||
|
||||
const deleteShoppingCart = () => {
|
||||
shoppingCartStore.deleteIfChecked();
|
||||
checkedAll.value = false;
|
||||
isEditMode.value = false;
|
||||
};
|
||||
|
||||
const showSkuDialog = (index: number) => {
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
<view class='integral-add-view'>
|
||||
<text>将会员卡放入微信卡包,及时了解积分变动</text>
|
||||
<text>去添加</text>
|
||||
<text @click.stop='openCard'>去添加</text>
|
||||
<image :src='assetsUrl("ic_arrow_right_yellow.png")' />
|
||||
</view>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<view v-for='(item,index) in orderActionList' :key='index' @click.stop='gotoPath(item.path)'>
|
||||
<image :src='item.icon' />
|
||||
<text>{{ item.title }}</text>
|
||||
<text v-if='index==0&&userInfo?.orderNum>0'>{{ userInfo?.orderNum }}</text>
|
||||
<text v-if='index==0&&unPaidOrderCount>0'>{{ unPaidOrderCount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -59,18 +59,27 @@
|
||||
<text>{{ item.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
<!-- 支付密码设置弹框 -->
|
||||
<pay-password-dialog ref="payPasswordDialogRef" />
|
||||
<official-account-dialog ref='officialAccountDialogRef' />
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { assetsUrl, defaultAvatar } from '@/utils/assets';
|
||||
import { goLogin, goPath, isLogin } from '@/utils';
|
||||
import { isPending } from '@/utils/order';
|
||||
import { getCardLink } from '@/api/user';
|
||||
import { getOrderList } from '@/api/order';
|
||||
import OfficialAccountDialog from '@/components/official-account-dialog.vue';
|
||||
import PayPasswordDialog from '@/components/pay-password-dialog.vue';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const officialAccountDialogRef = ref();
|
||||
const payPasswordDialogRef = ref<any>(null);
|
||||
|
||||
const orderActionList = ref([{
|
||||
title: '未支付',
|
||||
@@ -109,7 +118,12 @@ const serviceList = [
|
||||
}, {
|
||||
title: '联系商家',
|
||||
icon: assetsUrl('ic_member_service_contact.png'),
|
||||
path: ''
|
||||
path: '/pages/mine/subs/contact/index'
|
||||
},
|
||||
{
|
||||
title: '支付密码',
|
||||
icon: '/static/images/ic_member_pay_password.png',
|
||||
path: 'pay_password'
|
||||
}
|
||||
// ,{
|
||||
// title: '推广中心',
|
||||
@@ -118,34 +132,72 @@ const serviceList = [
|
||||
// }
|
||||
];
|
||||
|
||||
const title = ref<string>();
|
||||
title.value = import.meta.env.VITE_APP_TITLE;
|
||||
|
||||
const store = useUserStore();
|
||||
const { userInfo, companyConfigInfo } = storeToRefs(store);
|
||||
const { userInfo, companyInfo, companyConfigInfo } = storeToRefs(store);
|
||||
|
||||
const cardLink = ref('');
|
||||
const unPaidOrderCount = ref(0);
|
||||
|
||||
onLoad(() => {
|
||||
if(!isLogin()) {
|
||||
goLogin();
|
||||
return;
|
||||
// if(!isLogin()) {
|
||||
// goLogin();
|
||||
// return;
|
||||
// }
|
||||
});
|
||||
|
||||
onShow(async () => {
|
||||
if(isLogin()) {
|
||||
const { list } = await getOrderList({
|
||||
pageNum: 1,
|
||||
pageSize: 9999,
|
||||
obj: { payStatus: 1 }
|
||||
});
|
||||
unPaidOrderCount.value = list.filter((item: any) => isPending(item))?.length || 0;
|
||||
const { cardurl } = await getCardLink();
|
||||
cardLink.value = cardurl;
|
||||
await userStore.getProfile();
|
||||
}
|
||||
});
|
||||
|
||||
const gotoPath = (path: string) => {
|
||||
if(path === 'follow_official_account') {
|
||||
showOfficialAccountDialog();
|
||||
} else if(path === 'qrcode') {
|
||||
uni.switchTab({
|
||||
url: '/pages/qrcode/index'
|
||||
});
|
||||
} else {
|
||||
goPath(path);
|
||||
}
|
||||
const openCard = () => {
|
||||
// const url = 'https://mp.weixin.qq.com/bizmall/activatemembercard?action=preshow&&encrypt_card_id=LI%2FNyDp0x3z8XXorvvrHzSR4VUPa2vlioBg2xkDT3HqybiAFNsNgjH7pBpyKGrSA&outer_str=1702887425732870145&biz=MzU2MTg5MjgxMg%3D%3D#wechat_redirect';
|
||||
goPath(`/pages/common/webview/index?url=${encodeURIComponent(cardLink.value)}`);
|
||||
// uni.navigateToMiniProgram({ appId: 'wxeb490c6f9b154ef9' });
|
||||
// uni.addCard({
|
||||
// cardList: [
|
||||
// {
|
||||
// cardId: 'pzCtO1NU8FDcF3v09_Q76-7ZuN8I',
|
||||
// cardExt: JSON.stringify({ 'code': '12345', openId: 'wxc480826360455685', 'timestamp': Date.now(), 'signature': '' })
|
||||
// }
|
||||
// ]
|
||||
// });
|
||||
};
|
||||
|
||||
const showOfficialAccountDialog = () => {
|
||||
officialAccountDialogRef.value.show();
|
||||
};
|
||||
|
||||
const showPayPasswordDialog = () => {
|
||||
payPasswordDialogRef.value?.show();
|
||||
};
|
||||
|
||||
const gotoPath = (path: string) => {
|
||||
if(path === 'follow_official_account') {
|
||||
showOfficialAccountDialog();
|
||||
} else if(path === 'pay_password') {
|
||||
showPayPasswordDialog();
|
||||
} else if(path === 'qrcode') {
|
||||
uni.switchTab({
|
||||
url: '/pages/qrcode/index'
|
||||
});
|
||||
} else if(path === 'call') {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: companyInfo.value.telphone
|
||||
});
|
||||
} else {
|
||||
goPath(path, true);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
@@ -165,6 +217,7 @@ const showOfficialAccountDialog = () => {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
|
@@ -4,7 +4,8 @@
|
||||
<item v-for='(item,index) in addressList' :key='index' :item='item'
|
||||
@on-checked='onChecked(item)'
|
||||
@on-edit='args => goPath(`create?bean=${encodeURIComponent(JSON.stringify(args))}`)'
|
||||
@on-delete='args => {addressDelete(args?.addrid);fetchAddressList}' />
|
||||
@on-delete='args => {handleDelete(args)}' />
|
||||
<u-empty v-if='addressList.length === 0' text='暂无数据' margin-top='100' />
|
||||
</scroll-view>
|
||||
|
||||
<view class='bottom-button-view'>
|
||||
@@ -42,6 +43,23 @@ const fetchAddressList = async () => {
|
||||
addressList.value = await getAddressList();
|
||||
};
|
||||
|
||||
const handleDelete = async (item: any) => {
|
||||
uni.showModal(
|
||||
{
|
||||
title: '提示',
|
||||
content: '确定删除该地址吗?',
|
||||
success: async (res) => {
|
||||
if(res.confirm) {
|
||||
const result = await addressDelete(item?.addrid);
|
||||
if(result) {
|
||||
await fetchAddressList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const onChecked = (e: any) => {
|
||||
const pages = getCurrentPages();
|
||||
if(pages.length >= 2 && pages[pages.length - 2].route?.includes('pages/mall/subs/order/order-confirm')) {
|
||||
|
61
src/pages/mine/subs/contact/index.vue
Normal file
61
src/pages/mine/subs/contact/index.vue
Normal file
@@ -0,0 +1,61 @@
|
||||
<template>
|
||||
<view class='card-view'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='key'>姓名</text>
|
||||
<text class='value'>{{ companyConfigInfo?.contactname}}</text>
|
||||
</view>
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row'>
|
||||
<text class='key'>手机号</text>
|
||||
<text class='value'>{{companyConfigInfo?.contacttelephone}}</text>
|
||||
<image :src='assetsUrl("ic_contact_merchant.png")' @click.stop='call' />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { useUserStore } from '@/store';
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
|
||||
const { companyConfigInfo } = storeToRefs(useUserStore());
|
||||
const call = () => {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: companyConfigInfo.value.contacttelephone
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.card-view {
|
||||
background-color: #fff;
|
||||
padding: 30rpx 20rpx;
|
||||
margin: 24rpx;
|
||||
border-radius: 10rpx;
|
||||
|
||||
.divider {
|
||||
margin: 30rpx 0;
|
||||
}
|
||||
|
||||
.c-flex-row {
|
||||
.key {
|
||||
font-size: 30rpx;
|
||||
color: #7E7E7E;
|
||||
width: 120rpx;
|
||||
}
|
||||
|
||||
.value {
|
||||
display: flex;
|
||||
font-weight: 400;
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 39rpx;
|
||||
height: 41rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@@ -1,16 +1,16 @@
|
||||
<template>
|
||||
<view class='coupon-content'>
|
||||
<image v-if='item?.status==0' :src='assetsUrl("bg_coupon.png")' />
|
||||
<image v-else-if='item?.status==1' :src='assetsUrl("bg_coupon_expired.png")' />
|
||||
<view class='left-content accent-text-color' :class='{"left-content-disabled": item?.status==1}'>
|
||||
<image v-else-if='item?.status==1||item?.status==2' :src='assetsUrl("bg_coupon_expired.png")' />
|
||||
<view class='left-content accent-text-color' :class='{"left-content-disabled": item?.status!=0}'>
|
||||
<text>{{ item?.reduce }}</text>
|
||||
<text>满{{ item?.threshold }}元可用</text>
|
||||
</view>
|
||||
|
||||
<view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status==1}'>
|
||||
<view class='right-content accent-text-color' :class='{"right-content-disabled": item?.status!=0}'>
|
||||
<text>{{ item?.name }}</text>
|
||||
<text>有效期至{{ dayjs(item?.startTime).format('YYYY-MM-DD') }}</text>
|
||||
<text class='btn-text' :class='{"btn-text-disabled": item?.status==1}'>
|
||||
<text>有效期至{{ dayjs(item?.endTime).format('YYYY-MM-DD') }}</text>
|
||||
<text class='btn-text' :class='{"btn-text-disabled": item?.status!=0}' @click.stop='goPath("/pages/mall/index")'>
|
||||
立即使用
|
||||
</text>
|
||||
</view>
|
||||
@@ -24,6 +24,7 @@ import { assetsUrl } from '@/utils/assets';
|
||||
import dayjs from 'dayjs';
|
||||
import { PropType } from 'vue';
|
||||
import { CouponBean } from '@/api/user/types';
|
||||
import { goPath } from '@/utils';
|
||||
|
||||
defineProps({
|
||||
item: Object as PropType<CouponBean>
|
||||
@@ -79,7 +80,7 @@ defineProps({
|
||||
position: relative;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
margin-left: 60rpx;
|
||||
margin-left: 65rpx;
|
||||
|
||||
text:nth-of-type(1) {
|
||||
font-size: 30rpx;
|
||||
|
@@ -1,11 +1,14 @@
|
||||
<template>
|
||||
<tabbar :titles='["全部","未使用","已使用"]' :indicator-color='"#D95554"' @change='tabChange' />
|
||||
<scroll-view :scroll-y='true' class='content' @loadmore='onLoadMore'>
|
||||
<coupon-item v-for='item in coupons' :item='item' />
|
||||
</scroll-view>
|
||||
<u-list @scrolltolower='onLoadMore'>
|
||||
<coupon-item v-for='item in couponList' :item='item' :key='item.id' />
|
||||
<u-loadmore v-if='couponList.length>0' :status='loadingStatus' />
|
||||
<u-empty v-if='couponList.length === 0' text='暂无优惠券' marginTop='100' />
|
||||
</u-list>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import CouponItem from './components/coupon-item.vue';
|
||||
import { getCouponList } from '@/api/user';
|
||||
@@ -16,32 +19,54 @@ import { CouponBean } from '@/api/user/types';
|
||||
const store = useUserStore();
|
||||
const { userInfo } = storeToRefs(store);
|
||||
|
||||
const coupons = ref<CouponBean[]>([]);
|
||||
const couponStatus = ref<number | any>(undefined);
|
||||
const couponList = ref<CouponBean[]>([]);
|
||||
const currentPageNum = ref(1);
|
||||
const loadingStatus = ref('loading');
|
||||
|
||||
onLoad(async () => {
|
||||
await fetchData(0);
|
||||
await fetchData();
|
||||
});
|
||||
|
||||
const tabChange = (index: number) => {
|
||||
fetchData(index);
|
||||
switch (index) {
|
||||
case 0:
|
||||
couponStatus.value = undefined;
|
||||
break;
|
||||
case 1:
|
||||
couponStatus.value = 0;
|
||||
break;
|
||||
case 2:
|
||||
couponStatus.value = 1;
|
||||
break;
|
||||
}
|
||||
currentPageNum.value = 1;
|
||||
fetchData();
|
||||
};
|
||||
|
||||
const fetchData = async (status: number) => {
|
||||
const fetchData = async (refresh: boolean = true) => {
|
||||
loadingStatus.value = 'loading';
|
||||
if(!refresh) {
|
||||
currentPageNum.value += 1;
|
||||
}
|
||||
|
||||
const { list } = await getCouponList({
|
||||
companyId: getCompanyId(),
|
||||
memberId: userInfo.value?.id,
|
||||
status: status,
|
||||
pageNum: 1,
|
||||
status: couponStatus.value,
|
||||
pageNum: currentPageNum.value,
|
||||
pageSize: 20
|
||||
});
|
||||
coupons.value = list;
|
||||
if(refresh) {
|
||||
couponList.value = list;
|
||||
} else {
|
||||
couponList.value = couponList.value.concat(list);
|
||||
}
|
||||
loadingStatus.value = 'no';
|
||||
};
|
||||
|
||||
const onLoadMore = () => {
|
||||
if(coupons.value.length >= 20) {
|
||||
return;
|
||||
}
|
||||
fetchData(0);
|
||||
fetchData(false);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
<scroll-view style='margin: 10rpx 20rpx'>
|
||||
<u-list @scrolltolower='loadMore'>
|
||||
<integral-item v-for='(item,index) in tradeList' :key='index' :item='item' />
|
||||
<u-empty v-if='tradeList.length === 0' text='暂无数据' margin-top='100' />
|
||||
</u-list>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<image class='goods-image' :src='item?.orderGoods[0].images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1;'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='goods-name'>{{ item?.orderGoods[0].goodsName }}</text>
|
||||
<text class='goods-name'>{{ item?.orderGoods[0].goodsName || '未知' }}</text>
|
||||
<text class='status'>
|
||||
<text v-if='item?.payStatus == 2'>已支付</text>
|
||||
<text v-else-if='isPending(item)'>待支付</text>
|
||||
@@ -13,7 +13,7 @@
|
||||
</view>
|
||||
<view class='bottom-view c-flex-row'>
|
||||
<text>
|
||||
{{ item?.orderGoods[0].stockStock.colorName }},{{ item?.orderGoods[0].stockStock.sizeName }}
|
||||
{{ item?.orderGoods[0].stockStock.colorName||'均色' }},{{ item?.orderGoods[0].stockStock.sizeName||'均码' }}
|
||||
</text>
|
||||
<text>
|
||||
共{{ item?.itemNum }}件
|
||||
@@ -33,7 +33,8 @@
|
||||
|
||||
<view class='c-flex-row'>
|
||||
<text class='add-shoppingcart secondary-text-color' @click.stop='add(item?.orderGoods[0])'>加入购物车</text>
|
||||
<text class='payment accent-text-color' v-if='isPending(item)' @click.stop='goPath(`/pages/mine/subs/order/detail?orderId=${item?.id}`)'>立即支付
|
||||
<text class='payment accent-text-color' v-if='isPending(item)'
|
||||
@click.stop='goPath(`/pages/mine/subs/order/detail?orderId=${item?.id}`)'>立即支付
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -155,13 +156,14 @@ const pay = (orderId: string | undefined) => {
|
||||
}
|
||||
|
||||
.add-shoppingcart {
|
||||
border: 1rpx solid #ACACAC;
|
||||
border: 2rpx solid #ACACAC;
|
||||
}
|
||||
|
||||
|
||||
.payment {
|
||||
border: 1rpx solid #F32B2B;
|
||||
border: 2rpx solid #F32B2B;
|
||||
margin-left: 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,11 +18,14 @@
|
||||
<view class='address-view c-flex-column'
|
||||
v-if='orderBean?.order?.address'>
|
||||
<view class='user-info c-flex-row'>
|
||||
<text v-if='orderBean.order.address.defaultstatus==1'>默认</text>
|
||||
<text class='status' v-if='orderBean.order.address.defaultstatus==1'>默认</text>
|
||||
<text>{{ orderBean?.order?.address.name }}</text>
|
||||
<text>{{ orderBean?.order?.address.mobile }}</text>
|
||||
<view style='flex: 1' />
|
||||
<text style='color: #5B96FB'>复制</text>
|
||||
<text style='color: #5B96FB'
|
||||
@click.stop='copy(orderBean?.order?.address.name+","+orderBean?.order?.address.mobile+","+orderBean?.order?.address.addr)'>
|
||||
复制
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class='addr c-flex-row'>
|
||||
@@ -38,14 +41,14 @@
|
||||
<image class='goods-image' :src='item.stockStock.images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1;'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='goods-name'>{{ item.goodsName }}</text>
|
||||
<text class='goods-name'>{{ item.goodsName || '未知' }}</text>
|
||||
</view>
|
||||
<text style='color: #999999;margin-top: 30rpx'>
|
||||
{{ item.goodsCode }}
|
||||
</text>
|
||||
<view class='bottom-view c-flex-row'>
|
||||
<text>
|
||||
{{ item.stockStock.colorName }},{{ item.stockStock.sizeName }} x{{ item.goodsNum }}
|
||||
{{ item.stockStock.colorName||'均色' }},{{ item.stockStock.sizeName||'均码' }} x{{ item.goodsNum }}
|
||||
</text>
|
||||
<text>{{ item.consumePrice }}</text>
|
||||
</view>
|
||||
@@ -89,9 +92,15 @@
|
||||
|
||||
<view class='order-no c-flex-column'>
|
||||
<text>订单编号:{{ orderBean?.order?.id }}
|
||||
<text style='color: #5B96FB;margin-left: 10rpx'>复制</text>
|
||||
<text style='color: #5B96FB;margin-left: 10rpx' @click.stop='copy(orderBean?.order?.id||"")'>复制</text>
|
||||
</text>
|
||||
<text>下单时间:{{ orderBean?.order?.createTime }}</text>
|
||||
<text>
|
||||
支付状态:
|
||||
<text v-if='orderBean?.order?.payStatus == 2' style='color: #F32B2B'>已支付</text>
|
||||
<text v-else-if='isPending(orderBean?.order)' style='color: #F32B2B'>待支付</text>
|
||||
<text v-else style='color: #999999'>已过期</text>
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class='bottom-action-view c-flex-row' v-if='isPending(orderBean?.order)'>
|
||||
@@ -116,7 +125,7 @@
|
||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import { getOrderDetail } from '@/api/order';
|
||||
import { OrderBean } from '@/api/order/types';
|
||||
import { parseParameter, sortASCII } from '@/utils';
|
||||
import { copy, parseParameter, sortASCII } from '@/utils';
|
||||
import { hexMD5 } from '@/utils/common/md5';
|
||||
import { useUserStore } from '@/store';
|
||||
import { getOrderDeadline, handlePayResult, isPending } from '@/utils/order';
|
||||
@@ -155,7 +164,7 @@ const buildSqbParams = computed(() => {
|
||||
const params = sortASCII({
|
||||
client_sn: orderBean.value?.order?.id || '',
|
||||
return_url: '/pages/common/payresult/index',
|
||||
total_amount: ((orderBean.value?.order?.totalPrice || 0) * 100).toString(),
|
||||
total_amount: Number(((orderBean.value?.order?.totalPrice || 0) * 100).toFixed(2)),
|
||||
terminal_sn: terminalInfo.value.terminalSn,
|
||||
subject: '商品支付',
|
||||
merchant_name: terminalInfo.value.companyName,
|
||||
@@ -169,7 +178,7 @@ const buildSqbParams = computed(() => {
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.order.id, e, {
|
||||
onSuccess: () => {
|
||||
onSuccess: (options:any) => {
|
||||
fetchData(orderBean.value?.order.id || '');
|
||||
}
|
||||
});
|
||||
@@ -249,7 +258,7 @@ const payment = () => {
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
|
||||
text:nth-of-type(1) {
|
||||
.status {
|
||||
padding: 2rpx 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: #F32B2B;
|
||||
@@ -404,8 +413,8 @@ const payment = () => {
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
text:nth-of-type(1) {
|
||||
margin-bottom: 12rpx;
|
||||
text:nth-of-type(3) {
|
||||
margin-bottom: 0rpx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,11 +441,12 @@ const payment = () => {
|
||||
sqb-pay button {
|
||||
padding: 0 45rpx;
|
||||
border-radius: 50rpx;
|
||||
border: 1rpx solid #F32B2B;
|
||||
border: 2rpx solid #F32B2B;
|
||||
font-weight: bold;
|
||||
background: #FFFFFF;
|
||||
font-size: 30rpx;
|
||||
color: #F32B2B;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -4,7 +4,8 @@
|
||||
<u-list-item v-for='(item,index) in orderList' :key='index'>
|
||||
<order-item :item='item' @addShoppingCart='addShoppingCart' @pay='payment' />
|
||||
</u-list-item>
|
||||
<u-loadmore status='loading' />
|
||||
<u-loadmore v-if='orderList.length>0' :status='loadingStatus' />
|
||||
<u-empty v-if='orderList.length === 0' text='暂无数据' margin-top='100' />
|
||||
</u-list>
|
||||
<sku-dialog ref='skuDialogRef' :exists='temporaryStockBean' />
|
||||
|
||||
@@ -28,6 +29,7 @@ const temporaryStockBean = ref<StockBean>();
|
||||
const orderList = ref<OrderBean[]>([]);
|
||||
const currentPageNum = ref(1);
|
||||
const payStatus = ref(0);
|
||||
const loadingStatus = ref('loading');
|
||||
|
||||
let currentInterval = 0;
|
||||
|
||||
@@ -46,6 +48,7 @@ const tabChange = (index: number) => {
|
||||
};
|
||||
|
||||
const fetchData = async (refresh: boolean = true) => {
|
||||
loadingStatus.value = 'loading';
|
||||
if(!refresh) {
|
||||
currentPageNum.value += 1;
|
||||
}
|
||||
@@ -59,6 +62,7 @@ const fetchData = async (refresh: boolean = true) => {
|
||||
} else {
|
||||
orderList.value = orderList.value.concat(list);
|
||||
}
|
||||
loadingStatus.value = 'no';
|
||||
handleCountdown(orderList.value.filter(item => item.payStatus == 1));
|
||||
};
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<view class='top-card-view'>
|
||||
<image class='bg-image' :src='companyConfigInfo.userbgcover' />
|
||||
<image class='avatar-image' :src='params.image' />
|
||||
<text>{{ userInfo.name }}</text>
|
||||
<text>{{ userInfo.nickName }}</text>
|
||||
<text>{{ userInfo.levelName }}</text>
|
||||
</view>
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row'>
|
||||
<text>生日</text>
|
||||
<picker mode='date' :disabled='userInfo.birthday!=""' @change='changeDate'>
|
||||
<text>{{ params?.birthday || '请选择生日' }}</text>
|
||||
<picker mode='date' :disabled='(userInfo.birthday?.length||0)!=0' @change='changeDate'>
|
||||
<text>{{ dayjs(params?.birthday || Date.now()).format('YYYY-MM-DD') || '请选择生日' }}</text>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
@@ -80,7 +80,7 @@ const params = ref<{
|
||||
nickName: userInfo.value.nickName,
|
||||
telephone: userInfo.value.telephone,
|
||||
gender: userInfo.value.gender,
|
||||
birthday: userInfo.value.birthday
|
||||
birthday: userInfo.value.birthday || dayjs().format('YYYY-MM-DD')
|
||||
});
|
||||
|
||||
onLoad(() => {
|
||||
@@ -135,20 +135,19 @@ const save = async () => {
|
||||
|
||||
const result = await updateProfile({
|
||||
...params.value,
|
||||
birthday: dayjs(params.value.birthday).format('YYYY-MM-DD HH:mm:ss'),
|
||||
birthday: dayjs(params.value.birthday).isValid() ? dayjs(params.value.birthday).format('YYYY-MM-DD HH:mm:ss') : dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
birthdayType: 0
|
||||
});
|
||||
|
||||
if(result) {
|
||||
await store.setUserInfo(newUserInfo);
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
success(result) {
|
||||
showToast('修改成功', {
|
||||
icon: 'success', complete: () => {
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showToast('服务异常,操作失败', { icon: 'error' });
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<image :src='assetsUrl("bg_member_recharge.png")' />
|
||||
<view class='balance-content'>
|
||||
<text>累计余额(元)</text>
|
||||
<text>¥{{ userInfo?.totalIncoming}}</text>
|
||||
<text>¥{{ userInfo?.totalIncoming }}</text>
|
||||
</view>
|
||||
<view class='balance-content'>
|
||||
<text>当前余额(元)</text>
|
||||
@@ -13,17 +13,30 @@
|
||||
</view>
|
||||
|
||||
<view class='recharge-option-card'>
|
||||
<text>充值金额</text>
|
||||
<tabbar :titles='rechargeItems?.map(res=>res.rechargeamount)' @change='change' />
|
||||
<view class='divider' />
|
||||
<view class='option-item'>
|
||||
<image :src='assetsUrl("bg_member_recharge_item.png")' />
|
||||
<text>充值{{ rechargeItems[currentIndex]?.rechargeamount }}送{{ rechargeItems[currentIndex]?.rewardamount }}元
|
||||
</text>
|
||||
<text class='accent-text-color'>
|
||||
实得{{ rechargeItems[currentIndex]?.rechargeamount + (rechargeItems[currentIndex]?.rewardamount) }}元
|
||||
</text>
|
||||
</view>
|
||||
<view class='top-border'></view>
|
||||
<text class='title'>充值金额</text>
|
||||
<scroll-view scroll-y style='flex: 1;padding-bottom: 180rpx'>
|
||||
<view class='option-item' :class="{'option-item-active': currentIndex==index}"
|
||||
v-for='(item,index) in rechargeItems' :key='index' @click.stop='change(index)'>
|
||||
<image v-if='currentIndex==index' class='checked-image' src='/static/images/ic_recharge_checked.png' />
|
||||
<label class='amount-title'>{{ item.rechargeamount }}元</label>
|
||||
<view class='divider' style='margin-bottom: 36rpx' />
|
||||
<view class='card-view'>
|
||||
<view class='title-container'>
|
||||
<text>充值{{ item?.rechargeamount || 0 }}送{{ item?.rewardamount || 0
|
||||
}}元
|
||||
</text>
|
||||
<text class='accent-text-color'>
|
||||
实得{{ item?.rechargeamount + (item?.rewardamount) }}元
|
||||
</text>
|
||||
</view>
|
||||
<text class='description'>送{{ item.rewardamount || 0 }}元、送{{ item.rewardcouponamount || 0
|
||||
}}元优惠券共{{ item.rewardcouponnum || 0 }}张、
|
||||
返利{{ item.rewardrefundamount || 0 }}元
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<view class='bottom-button-view'>
|
||||
@@ -47,7 +60,7 @@
|
||||
<script lang='ts' setup>
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import { useUserStore } from '@/store';
|
||||
import { getRechargeList, preRecharge, recharge, rechargeVerify } from '@/api/user';
|
||||
import { getRechargeList, preRecharge, rechargeVerify } from '@/api/user';
|
||||
import { parseParameter, sortASCII } from '@/utils';
|
||||
import { hexMD5 } from '@/utils/common/md5';
|
||||
import { handlePayResult } from '@/utils/order';
|
||||
@@ -55,12 +68,16 @@ import { handlePayResult } from '@/utils/order';
|
||||
const userState = useUserStore();
|
||||
const { userInfo, terminalInfo } = storeToRefs(userState);
|
||||
|
||||
const rechargeOptionBackgroundUrl = assetsUrl('bg_member_recharge_item.png');
|
||||
|
||||
const rechargeItems = ref<{
|
||||
itemid: string
|
||||
rechargeamount: number
|
||||
rewardamount: number
|
||||
rewardcouponamount: number,
|
||||
rechargetype: number
|
||||
rewardcouponnum: number
|
||||
rechargetype: number,
|
||||
rewardrefundamount: number
|
||||
}[]>([]);
|
||||
const currentIndex = ref<number>(0);
|
||||
const preRechargeOrderId = ref();
|
||||
@@ -68,6 +85,12 @@ const preRechargeOrderId = ref();
|
||||
onLoad(async () => {
|
||||
const { ruleitems } = await getRechargeList();
|
||||
rechargeItems.value = ruleitems;
|
||||
// rechargeItems.value.push(rechargeItems.value[0]);
|
||||
// rechargeItems.value.push(rechargeItems.value[0]);
|
||||
// rechargeItems.value.push(rechargeItems.value[0]);
|
||||
// rechargeItems.value.push(rechargeItems.value[0]);
|
||||
|
||||
console.log(rechargeItems.value);
|
||||
await change(0);
|
||||
});
|
||||
|
||||
@@ -83,7 +106,7 @@ const buildSqbParams = computed(() => {
|
||||
const params = sortASCII({
|
||||
client_sn: preRechargeOrderId.value,
|
||||
return_url: '/pages/common/payresult/index',
|
||||
total_amount: ((rechargeItems.value[currentIndex.value]?.rechargeamount || 0) * 100).toString(),
|
||||
total_amount: Number(((rechargeItems.value[currentIndex.value]?.rechargeamount || 0) * 100).toFixed(2)),
|
||||
terminal_sn: terminalInfo.value.terminalSn,
|
||||
subject: '充值',
|
||||
merchant_name: terminalInfo.value.companyName,
|
||||
@@ -97,27 +120,24 @@ const buildSqbParams = computed(() => {
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(preRechargeOrderId.value, e, {
|
||||
onSuccess: async () => {
|
||||
console.log('---------->>> recharge success ');
|
||||
onSuccess: async (options: any) => {
|
||||
await goRecharge();
|
||||
await userState.setUserInfo({
|
||||
...userInfo.value,
|
||||
balance: Number(userInfo.value.balance) + Number(rechargeItems.value[currentIndex.value].rechargeamount) + Number(rechargeItems.value[currentIndex.value]?.rewardamount)
|
||||
});
|
||||
await uni.navigateBack();
|
||||
},
|
||||
onFailure: () => {
|
||||
console.log('---------->>> recharge failure ');
|
||||
onFailure: (e: any) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const goRecharge = async () => {
|
||||
console.log(buildSqbParams.value);
|
||||
const result = await recharge({
|
||||
itemid: rechargeItems.value[currentIndex.value].itemid
|
||||
});
|
||||
console.log('platform recharge result ', result);
|
||||
|
||||
// const result = await recharge({
|
||||
// itemid: rechargeItems.value[currentIndex.value].itemid
|
||||
// });
|
||||
// console.log('platform recharge result ', result);
|
||||
await rechargeVerify({
|
||||
payid: preRechargeOrderId.value
|
||||
});
|
||||
@@ -161,53 +181,109 @@ const goRecharge = async () => {
|
||||
.recharge-option-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #FFFFFF;
|
||||
border-radius: 30rpx 30rpx 0 0;
|
||||
background: #F5F5F5;
|
||||
position: relative;
|
||||
margin-top: -25rpx;
|
||||
//margin-top: -25rpx;
|
||||
|
||||
text:nth-of-type(1) {
|
||||
.top-border {
|
||||
background: #FFFFFF;
|
||||
height: 30rpx;
|
||||
margin-top: -35rpx;
|
||||
border-radius: 30rpx 30rpx 0 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
margin-top: 20rpx;
|
||||
margin-left: 30rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 10rpx 10rpx 0 0;
|
||||
padding: 10rpx 20rpx 20rpx 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
margin-top: -15rpx;
|
||||
}
|
||||
|
||||
.option-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 10rpx 20rpx 20rpx 20rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 20rpx;
|
||||
padding-top: 20rpx;
|
||||
box-sizing: border-box;
|
||||
border: solid #00000000 2rpx;
|
||||
position: relative;
|
||||
margin: 36rpx 20rpx;
|
||||
|
||||
image {
|
||||
.amount-title {
|
||||
font-weight: bold;
|
||||
font-size: 40rpx;
|
||||
width: fit-content;
|
||||
color: #333333;
|
||||
margin-left: 30rpx;
|
||||
}
|
||||
|
||||
.amount-title:after {
|
||||
content: "";
|
||||
display: block;
|
||||
border: 2rpx solid black;
|
||||
}
|
||||
|
||||
.checked-image {
|
||||
width: 70rpx;
|
||||
height: 70rpx;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
border-radius: 0 18rpx 0 0
|
||||
}
|
||||
|
||||
.card-view {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
height: 167rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
text:nth-of-type(1) {
|
||||
font-size: 36rpx;
|
||||
//background-image: url(v-bind(rechargeOptionBackgroundUrl));
|
||||
background-image: url('https://img.lakeapp.cn/wx/images/bg_member_recharge_item.png');
|
||||
background-size: 100% 100%;
|
||||
justify-content: flex-start;
|
||||
color: #FFFFFF;
|
||||
margin-top: 27rpx;
|
||||
margin-left: 30rpx;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
text:nth-of-type(2) {
|
||||
display: flex;
|
||||
font-size: 30rpx;
|
||||
margin-top: 85rpx;
|
||||
margin-left: 30rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 185rpx;
|
||||
height: 50rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 25rpx;
|
||||
position: absolute;
|
||||
.title-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 27rpx;
|
||||
padding: 0 30rpx;
|
||||
|
||||
text:nth-of-type(1) {
|
||||
display: flex;
|
||||
font-size: 36rpx;
|
||||
}
|
||||
|
||||
text:nth-of-type(2) {
|
||||
display: flex;
|
||||
font-size: 30rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 185rpx;
|
||||
height: 50rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 25rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.description {
|
||||
margin-top: 30rpx;
|
||||
margin-left: 30rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.option-item-active {
|
||||
@extend .option-item;
|
||||
border: 2rpx solid #f95e5d;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -4,7 +4,8 @@
|
||||
<!-- <view class='item c-flex-column' v-for='(item,index) in 3' :key='index'>-->
|
||||
<view class='c-flex-row'>
|
||||
<text class='primary-text-color' style='flex: 1'>{{ item.name }}</text>
|
||||
<text class='accent-text-color'>-{{ item.transactionPrice || 0 }}</text>
|
||||
<text class='accent-text-color'>{{item.type===1?'-':'+'}}{{
|
||||
item.transactionPrice || 0 }}</text>
|
||||
</view>
|
||||
<view class='c-flex-row'>
|
||||
<text class='secondary-text-color' style='flex: 1'>{{ item.createTime }}</text>
|
||||
@@ -28,7 +29,7 @@ defineProps({
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 16rpx 23rpx 20rpx 30rpx;
|
||||
margin: 10rpx 0;
|
||||
margin: 20rpx 0 10rpx 0;
|
||||
}
|
||||
|
||||
.category-title {
|
||||
|
@@ -2,33 +2,34 @@
|
||||
<tabbar :titles='["全部","充值","消费"]' @change='changeTab' :item-active-color='"#D95554"'
|
||||
:indicator-color='"#D95554"' />
|
||||
<view class='content'>
|
||||
<view class='c-flex-row'>
|
||||
<text>选择日期</text>
|
||||
<picker mode='date' @change='changeDate'>
|
||||
<view class='current-date c-flex-row'>
|
||||
<text>{{ tradeDate }}</text>
|
||||
<image :src='assetsUrl("ic_triangle_down.png")' />
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
<!-- <view class='c-flex-row'>-->
|
||||
<!-- <text>选择日期</text>-->
|
||||
<!-- <picker mode='date' @change='changeDate'>-->
|
||||
<!-- <view class='current-date c-flex-row'>-->
|
||||
<!-- <text>{{ tradeDate }}</text>-->
|
||||
<!-- <image :src='assetsUrl("ic_triangle_down.png")' />-->
|
||||
<!-- </view>-->
|
||||
<!-- </picker>-->
|
||||
<!-- </view>-->
|
||||
|
||||
<u-list @scrolltolower='loadMore'>
|
||||
<trade-item v-for='(item,index) in tradeList' :key='index' :item='item' />
|
||||
<u-loadmore status='loading' />
|
||||
<u-loadmore v-if='tradeList.length>0' :status='loadingStatus' />
|
||||
<u-empty v-if='tradeList.length === 0' text='暂无数据' margin-top='100' />
|
||||
</u-list>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import TradeItem from './components/trade-item.vue';
|
||||
import { getTradeList } from '@/api/user';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const tradeList = ref([]);
|
||||
const tradeType = ref('全部');
|
||||
const tradeType = ref('');
|
||||
const tradeDate = ref();
|
||||
const currentPageNum = ref(1);
|
||||
const loadingStatus = ref('loading');
|
||||
|
||||
onLoad((e) => {
|
||||
tradeDate.value = dayjs(Date.now()).format('YYYY-MM-DD');
|
||||
@@ -43,7 +44,7 @@ const changeDate = (e: any) => {
|
||||
const changeTab = (index: number) => {
|
||||
switch (index) {
|
||||
case 0:
|
||||
tradeType.value = '全部';
|
||||
tradeType.value = '';
|
||||
break;
|
||||
case 1:
|
||||
tradeType.value = '会员充值';
|
||||
@@ -57,9 +58,10 @@ const changeTab = (index: number) => {
|
||||
|
||||
const fetchData = async (refresh: boolean = true) => {
|
||||
currentPageNum.value = refresh ? 1 : currentPageNum.value + 1;
|
||||
loadingStatus.value = 'loading';
|
||||
const { list } = await getTradeList({
|
||||
startDate: tradeDate.value,
|
||||
endDate: tradeDate.value,
|
||||
// startDate: tradeDate.value,
|
||||
// endDate: dayjs(tradeDate.value).add(1, 'day').format('YYYY-MM-DD'),
|
||||
name: tradeType.value,
|
||||
pageNum: currentPageNum.value,
|
||||
pageSize: 20
|
||||
@@ -69,6 +71,7 @@ const fetchData = async (refresh: boolean = true) => {
|
||||
} else {
|
||||
tradeList.value = tradeList.value.concat(list);
|
||||
}
|
||||
loadingStatus.value = 'no';
|
||||
};
|
||||
|
||||
const loadMore = () => {
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<view class='qrcode-card'>
|
||||
<view class='balance-view'>
|
||||
<text class='balance-text'>账户余额:{{ userInfo?.balance || 0 }}元</text>
|
||||
<view class='btn-recharge' @click.stop='goPath("/pages/mine/subs/recharge/index")'>
|
||||
<view class='btn-recharge' @click.stop='goPath("/pages/mine/subs/recharge/index",true)'>
|
||||
<text>去充值</text>
|
||||
<image :src='assetsUrl("ic_arrow_right.png")' />
|
||||
</view>
|
||||
@@ -33,10 +33,9 @@
|
||||
<text>卡信息</text>
|
||||
</view>
|
||||
|
||||
<text>店铺名称({{ userInfo?.creatorName }})</text>
|
||||
<text>{{ getStoreName() }}</text>
|
||||
<text>{{ userInfo?.storeId }}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -47,7 +46,7 @@ import { assetsUrl } from '@/utils/assets';
|
||||
import { generateBarCode, generateQrCode } from '@/api/common';
|
||||
import { getDynamicCode } from '@/api/user';
|
||||
import { useUserStore } from '@/store';
|
||||
import { goLogin, goPath, isLogin } from '@/utils';
|
||||
import { goPath, isLogin } from '@/utils';
|
||||
|
||||
const store = useUserStore();
|
||||
const { userInfo } = storeToRefs(store);
|
||||
@@ -58,7 +57,7 @@ const codeRefreshInterval = ref(30);
|
||||
|
||||
onLoad(() => {
|
||||
if(!isLogin()) {
|
||||
goLogin();
|
||||
// goLogin();
|
||||
return;
|
||||
}
|
||||
generateCode();
|
||||
@@ -72,6 +71,10 @@ onLoad(() => {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
const getStoreName = () => {
|
||||
return `${userInfo.value?.nickName || userInfo.value?.name}(${userInfo.value?.storeName || userInfo.value?.companyName || userInfo.value?.creatorName})`;
|
||||
};
|
||||
|
||||
const generateCode = async () => {
|
||||
const { dynccode } = await getDynamicCode();
|
||||
codeContent.value = dynccode;
|
||||
|
28
src/pages/tab/user/index.vue
Normal file
28
src/pages/tab/user/index.vue
Normal file
@@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<view class="user-page">
|
||||
<!-- 其他现有内容 -->
|
||||
|
||||
<!-- 在联系商家后面添加支付密码设置入口 -->
|
||||
<u-cell-group>
|
||||
<!-- 现有的联系商家单元格 -->
|
||||
<u-cell
|
||||
title="支付密码"
|
||||
is-link
|
||||
@click="navigateToPayPassword"
|
||||
/>
|
||||
</u-cell-group>
|
||||
|
||||
<!-- 其他现有内容 -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// ... 其他导入 ...
|
||||
|
||||
// 跳转到支付密码设置页面
|
||||
const navigateToPayPassword = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/pay-password/index'
|
||||
})
|
||||
}
|
||||
</script>
|
@@ -3,7 +3,9 @@ import { getToken } from '@/utils/auth';
|
||||
// 登录页面
|
||||
const loginPage = '/pages/common/login/index';
|
||||
// 页面白名单
|
||||
const whiteList = ['/', '/pages/common/login/index', '/pages/home/index'];
|
||||
const whiteList = ['/', '/pages/common/login/index', '/pages/home/index','/pages/common/register/index',
|
||||
'/pages/common/register/reward',
|
||||
'/pages/mine/index','/pages/mine/subs/order/index'];
|
||||
|
||||
// 检查地址白名单
|
||||
function checkWhite(url: string) {
|
||||
@@ -23,11 +25,12 @@ list.forEach((item) => {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (checkWhite(to.url))
|
||||
return true;
|
||||
|
||||
uni.reLaunch({ url: loginPage });
|
||||
return false;
|
||||
// if (checkWhite(to.url))
|
||||
// return true;
|
||||
//
|
||||
// uni.reLaunch({ url: loginPage });
|
||||
// return false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"projectname": "肃客会员",
|
||||
"projectname": "VIP顾客中心",
|
||||
"setting": {
|
||||
"compileHotReLoad": true
|
||||
}
|
||||
|
BIN
src/static/images/ic_checked_gray.png
Normal file
BIN
src/static/images/ic_checked_gray.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
src/static/images/ic_checked_green.png
Normal file
BIN
src/static/images/ic_checked_green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
src/static/images/ic_checkmark_red.png
Normal file
BIN
src/static/images/ic_checkmark_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
src/static/images/ic_member_pay_password.png
Normal file
BIN
src/static/images/ic_member_pay_password.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
src/static/images/ic_recharge_checked.png
Normal file
BIN
src/static/images/ic_recharge_checked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
@@ -76,4 +76,17 @@ page {
|
||||
justify-content: center;
|
||||
min-width: 80%;
|
||||
color: #FFFFFF;
|
||||
border: none !important;
|
||||
outline: none;
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.disabled-button {
|
||||
@extend .primary-button;
|
||||
background: #cccccc;
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
@@ -4,18 +4,19 @@ import { getCompanyId } from '@/utils';
|
||||
|
||||
const useShoppingCartStore = defineStore('shoppingCart', {
|
||||
state: (): { shoppingCartList: GoodsBean[] } => ({
|
||||
shoppingCartList: []
|
||||
shoppingCartList: uni.getStorageSync(`shoppingCart_${getCompanyId()}`) === '' ? [] : uni.getStorageSync(`shoppingCart_${getCompanyId()}`) as GoodsBean[]
|
||||
}),
|
||||
|
||||
persist: {
|
||||
// 修改存储中使用的键名称,默认为当前 Store的 id
|
||||
key: 'shoppingCartState_' + getCompanyId(),
|
||||
key: 'shoppingCartState',
|
||||
storage: {
|
||||
setItem(key, value) {
|
||||
uni.setStorageSync(key, value); // [!code warning]
|
||||
uni.setStorageSync(`shoppingCart_${getCompanyId()}`, JSON.parse(value).shoppingCartList);
|
||||
},
|
||||
getItem(key) {
|
||||
return uni.getStorageSync(key); // [!code warning]
|
||||
return uni.getStorageSync(uni.getStorageSync(`shoppingCart_${getCompanyId()}`)) || '';
|
||||
}
|
||||
},
|
||||
// 部分持久化状态的点符号路径数组,[]意味着没有状态被持久化(默认为undefined,持久化整个状态)
|
||||
@@ -23,21 +24,28 @@ const useShoppingCartStore = defineStore('shoppingCart', {
|
||||
},
|
||||
|
||||
getters: {
|
||||
getShoppingCartList(): any[] {
|
||||
getShoppingCartList(): GoodsBean[] {
|
||||
return this.shoppingCartList;
|
||||
},
|
||||
|
||||
getTotalCount(): number {
|
||||
totalCount(): number {
|
||||
return this.shoppingCartList.length;
|
||||
},
|
||||
|
||||
getSameGoodsIndex: (state) => (goodsId: string, colorId: string, sizeId: string) => {
|
||||
return state.shoppingCartList.findIndex(res => res.id === goodsId && res.checkedStock.colorId === colorId && res.checkedStock.sizeId === sizeId);
|
||||
if(Array.isArray(state.shoppingCartList)) {
|
||||
return state.shoppingCartList?.findIndex(res => res.id === goodsId && res.checkedStock.colorId === colorId && res.checkedStock.sizeId === sizeId);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
save(partial: Partial<GoodsBean>) {
|
||||
if(!Array.isArray(this.shoppingCartList)) {
|
||||
this.shoppingCartList = [];
|
||||
}
|
||||
this.shoppingCartList.push(partial as GoodsBean);
|
||||
},
|
||||
|
||||
@@ -57,6 +65,10 @@ const useShoppingCartStore = defineStore('shoppingCart', {
|
||||
this.shoppingCartList = this.shoppingCartList.filter(res => res.checked == undefined || res.checked === false);
|
||||
},
|
||||
|
||||
resetData() {
|
||||
this.shoppingCartList = uni.getStorageSync(`shoppingCart_${getCompanyId()}`);
|
||||
},
|
||||
|
||||
clearAll() {
|
||||
this.shoppingCartList = [];
|
||||
}
|
||||
|
@@ -1,14 +1,24 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import type { providerType, UserBean } from './types';
|
||||
import { getTerminal, getUserProfile, login, logout as userLogout, register } from '@/api/user/index';
|
||||
import { clearToken, setCompanyId, setToken } from '@/utils/auth';
|
||||
import type { LoginResult, RegisterParams, TerminalBean } from '@/api/user/types';
|
||||
import {
|
||||
clearToken,
|
||||
getCompanyId,
|
||||
getRegisterStoreId,
|
||||
setCompanyId,
|
||||
setOpenId,
|
||||
setSessionKey,
|
||||
setToken
|
||||
} from '@/utils/auth';
|
||||
import type { RegisterParams, TerminalBean,SetPayPasswordParams } from '@/api/user/types';
|
||||
import { getCompanyInfo } from '@/api/company';
|
||||
import { setPayPassword } from '@/api/user'
|
||||
|
||||
const useUserStore = defineStore('user', {
|
||||
state: () => ({
|
||||
userInfo: {} as UserBean,
|
||||
terminalInfo: {} as TerminalBean,
|
||||
companyInfo: {} as any,
|
||||
companyConfigInfo: {
|
||||
bannerhot: [] as any[],
|
||||
bannerinx: [] as any[],
|
||||
@@ -16,7 +26,10 @@ const useUserStore = defineStore('user', {
|
||||
goodsstockzero: 0,
|
||||
mallopen: 0,
|
||||
regqrcode: undefined,
|
||||
userbgcover: undefined
|
||||
userbgcover: undefined,
|
||||
groupqrcode: undefined,
|
||||
contactname: '',
|
||||
contacttelephone: ''
|
||||
},
|
||||
deliveryAddress: {
|
||||
addrid: '',
|
||||
@@ -24,7 +37,7 @@ const useUserStore = defineStore('user', {
|
||||
mobile: '',
|
||||
addr: '',
|
||||
defaultstatus: 0
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
persist: {
|
||||
@@ -43,58 +56,22 @@ const useUserStore = defineStore('user', {
|
||||
},
|
||||
|
||||
getters: {
|
||||
// getUserInfo(state: UserState): UserState {
|
||||
// return state.address;
|
||||
// }
|
||||
getUserDiscount(): number {
|
||||
if(this.userInfo?.levelEntity?.discount > 0 && this.userInfo?.levelEntity?.discount < 10) {
|
||||
return this.userInfo?.levelEntity?.discount / 10;
|
||||
} else if(this.userInfo?.levelEntity?.discount >= 10 && this.userInfo?.levelEntity?.discount <= 100) {
|
||||
return this.userInfo?.levelEntity?.discount / 100;
|
||||
}
|
||||
return 1;
|
||||
},
|
||||
|
||||
getRealGoodsPrice: (state) => (price: number, priceExt: number) => {
|
||||
return state.userInfo.salePrice == 'price_ext' ? priceExt || 0 : price;
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 设置用户的信息
|
||||
async setUserInfo(partial: Partial<UserBean>) {
|
||||
this.userInfo = partial as UserBean;
|
||||
await setCompanyId(this.userInfo.companyId);
|
||||
await this.fetchTerminal();
|
||||
await this.fetchCompanyInfo();
|
||||
},
|
||||
|
||||
setDeliveryAddress(partial: Partial<any>) {
|
||||
this.deliveryAddress = partial as any;
|
||||
},
|
||||
|
||||
// 重置用户信息
|
||||
resetInfo() {
|
||||
this.$reset();
|
||||
},
|
||||
// 获取用户信息
|
||||
async getProfile() {
|
||||
const result = await getUserProfile();
|
||||
await this.setUserInfo(result);
|
||||
},
|
||||
|
||||
async fetchCompanyInfo() {
|
||||
this.companyConfigInfo = await getCompanyInfo();
|
||||
},
|
||||
|
||||
userRegister(registerForm: RegisterParams) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const result = await register(registerForm);
|
||||
resolve(result);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Logout
|
||||
async logout() {
|
||||
await userLogout();
|
||||
this.resetInfo();
|
||||
clearToken();
|
||||
},
|
||||
|
||||
// 小程序授权登录
|
||||
authLogin(provider: providerType = 'weixin') {
|
||||
login(provider: providerType = 'weixin') {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
provider,
|
||||
@@ -108,50 +85,131 @@ const useUserStore = defineStore('user', {
|
||||
signature: wechatUserInfo?.signature,
|
||||
iv: wechatUserInfo.iv
|
||||
};
|
||||
|
||||
getApp().globalData?.logger.info('login params: ', userInfo);
|
||||
const res = await login({
|
||||
code: result.code,
|
||||
userInfo: userInfo,
|
||||
referrerUserId: '1727303781559697409'
|
||||
storeId: getRegisterStoreId()
|
||||
// referrerUserId: '1727303781559697409'
|
||||
// referrerUserId: getReferrerUserId()
|
||||
});
|
||||
|
||||
if(res.user == undefined || res.user.id === null) {
|
||||
const registerForm = {
|
||||
unionId: res.user.unionId,
|
||||
openId: res.user.openId,
|
||||
maOpenId: res.user.maOpenId,
|
||||
image: res.user.image,
|
||||
nickName: res.user.nickName,
|
||||
telephone: res.user.telephone,
|
||||
birthday: res.user.birthday,
|
||||
companyId: res.user.companyId,
|
||||
creatorId: res.user.creatorId,
|
||||
gender: res.user.gender
|
||||
};
|
||||
setToken(res.token);
|
||||
const registerResult = await this.userRegister(registerForm);
|
||||
await this.setUserInfo(registerResult as LoginResult);
|
||||
getApp().globalData?.logger.info('login result: ', res);
|
||||
setToken(res.token);
|
||||
setSessionKey(res.sessionKey);
|
||||
setOpenId(res.maOpenId);
|
||||
if(res.user) {
|
||||
this.setUserInfo(res.user);
|
||||
} else {
|
||||
setToken(res.token);
|
||||
await this.setUserInfo(res.user);
|
||||
this.setUserInfo(res.userInfo);
|
||||
}
|
||||
// }
|
||||
resolve(res);
|
||||
} else {
|
||||
getApp().globalData?.logger.error('login error: ', result.errMsg);
|
||||
reject(new Error(result.errMsg));
|
||||
}
|
||||
},
|
||||
fail: (err: any) => {
|
||||
console.error(`login error: ${err}`);
|
||||
getApp().globalData?.logger.error('login error: ', err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
async fetchTerminal() {
|
||||
this.terminalInfo = await getTerminal(this.userInfo.companyId);
|
||||
}
|
||||
register(params: {
|
||||
image: string,
|
||||
avatarUrl: string,
|
||||
nickName: string,
|
||||
telephone: string,
|
||||
birthday: string,
|
||||
gender: string
|
||||
}) {
|
||||
const registerForm = {
|
||||
...params,
|
||||
unionId: this.userInfo.unionId,
|
||||
openId: this.userInfo.openId,
|
||||
maOpenId: this.userInfo.maOpenId,
|
||||
companyId: getApp()?.globalData?.shareCompanyId || getCompanyId(),
|
||||
creatorId: this.userInfo.creatorId,
|
||||
storeId: getApp()?.globalData?.shareStoreId || getRegisterStoreId()
|
||||
} as RegisterParams;
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const result = await register(registerForm);
|
||||
resolve(result);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 设置用户的信息
|
||||
async setUserInfo(partial: Partial<UserBean>) {
|
||||
this.userInfo = partial as UserBean;
|
||||
// this.userInfo.levelEntity?.discount = 79;
|
||||
// this.userInfo.salePrice = 'price_ext';
|
||||
if(this.userInfo) {
|
||||
this.userInfo.userDiscount = this.getUserDiscount;
|
||||
await setCompanyId(this.userInfo.companyId);
|
||||
if(getApp().globalData) {
|
||||
getApp().globalData!.companyId = this.userInfo.companyId;
|
||||
}
|
||||
this.fetchTerminal(this.userInfo?.companyId);
|
||||
this.fetchCompanyInfo();
|
||||
} else {
|
||||
await clearToken();
|
||||
}
|
||||
},
|
||||
|
||||
setCompanyInfo(partial: Partial<any>) {
|
||||
this.companyInfo = partial as any;
|
||||
if(getApp()?.globalData) {
|
||||
getApp().globalData!.companyId = this.companyInfo.id;
|
||||
}
|
||||
},
|
||||
|
||||
setDeliveryAddress(partial: Partial<any>) {
|
||||
this.deliveryAddress = partial as any;
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
async getProfile() {
|
||||
const result = await getUserProfile();
|
||||
await this.setUserInfo(result);
|
||||
},
|
||||
|
||||
async fetchCompanyInfo() {
|
||||
this.companyConfigInfo = await getCompanyInfo();
|
||||
},
|
||||
|
||||
async fetchTerminal(companyId: string = '') {
|
||||
this.terminalInfo = await getTerminal(companyId || this.userInfo.companyId);
|
||||
},
|
||||
|
||||
// 重置用户信息
|
||||
resetInfo() {
|
||||
this.$reset();
|
||||
},
|
||||
|
||||
// Logout
|
||||
async logout() {
|
||||
await userLogout();
|
||||
this.resetInfo();
|
||||
clearToken();
|
||||
},
|
||||
|
||||
// 设置支付密码
|
||||
async setPayPassword(params: SetPayPasswordParams) {
|
||||
const res = await setPayPassword(params)
|
||||
if (res.success) {
|
||||
this.userInfo.paywithpwd = 1
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export default useUserStore;
|
||||
|
@@ -9,11 +9,12 @@ export interface UserBean {
|
||||
birthdayType: number;
|
||||
card: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
consumption: string;
|
||||
consumptionDay: string;
|
||||
couponsCount: number;
|
||||
createTime: string;
|
||||
creatorId: string;
|
||||
creatorId: string;
|
||||
creatorName: string;
|
||||
customerPrice: string;
|
||||
email: string;
|
||||
@@ -38,10 +39,11 @@ export interface UserBean {
|
||||
registerDay: number;
|
||||
relatedRate: number;
|
||||
remark: string;
|
||||
salePrice: number;
|
||||
salePrice: string;
|
||||
source: string;
|
||||
status: string;
|
||||
storeId: string;
|
||||
storeName: string;
|
||||
telephone: string;
|
||||
totalConsumption: string;
|
||||
totalIncoming: number;
|
||||
@@ -50,6 +52,8 @@ export interface UserBean {
|
||||
updateTime: string;
|
||||
useCouponsPrice: number;
|
||||
wirelinedTelephone: string;
|
||||
userDiscount: number;
|
||||
paywithpwd: number;
|
||||
}
|
||||
|
||||
export type providerType =
|
||||
|
@@ -1,4 +1,3 @@
|
||||
export const assetsUrl = (name: string) => `https://img.lakeapp.cn/wx/images/${name}`;
|
||||
export const defaultAvatar = 'https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132';
|
||||
|
||||
export const defaultImage = '/static/images/ic_noimage.svg';
|
||||
|
@@ -1,5 +1,10 @@
|
||||
const TokenKey = 'accessToken';
|
||||
const SessionKey = 'sessionKey';
|
||||
const OpenIdKey = 'openId';
|
||||
const CompanyIdKey = 'companyId';
|
||||
const ReferrerUserIdKey = 'referrerUserId';
|
||||
const RegisterStoreIdKey = 'storeId';
|
||||
|
||||
const TokenPrefix = 'Bearer ';
|
||||
|
||||
function isLogin() {
|
||||
@@ -14,17 +19,71 @@ function setToken(token: string) {
|
||||
uni.setStorageSync(TokenKey, token);
|
||||
}
|
||||
|
||||
function getSessionKey() {
|
||||
return uni.getStorageSync(SessionKey);
|
||||
}
|
||||
|
||||
function setSessionKey(sessionKey: string) {
|
||||
uni.setStorageSync(SessionKey, sessionKey);
|
||||
}
|
||||
|
||||
function getOpenId() {
|
||||
return uni.getStorageSync(OpenIdKey);
|
||||
}
|
||||
|
||||
function setOpenId(openId: string) {
|
||||
uni.setStorageSync(OpenIdKey, openId);
|
||||
}
|
||||
|
||||
function getCompanyId() {
|
||||
return uni.getStorageSync(CompanyIdKey);
|
||||
}
|
||||
|
||||
function setCompanyId(companyId: string) {
|
||||
uni.setStorageSync(CompanyIdKey, companyId);
|
||||
if(companyId) {
|
||||
uni.setStorageSync(CompanyIdKey, companyId);
|
||||
if(getApp()?.globalData) {
|
||||
getApp().globalData!.companyId = companyId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getReferrerUserId() {
|
||||
return uni.getStorageSync(ReferrerUserIdKey);
|
||||
}
|
||||
|
||||
function setReferrerUserId(referrerUserId: string) {
|
||||
uni.setStorageSync(ReferrerUserIdKey, referrerUserId);
|
||||
}
|
||||
|
||||
function setRegisterStoreId(storeId: string) {
|
||||
uni.setStorageSync(RegisterStoreIdKey, storeId);
|
||||
}
|
||||
|
||||
function getRegisterStoreId() {
|
||||
return uni.getStorageSync(RegisterStoreIdKey);
|
||||
}
|
||||
|
||||
function clearToken() {
|
||||
uni.removeStorageSync(TokenKey);
|
||||
uni.removeStorageSync(CompanyIdKey);
|
||||
uni.removeStorageSync(SessionKey);
|
||||
}
|
||||
|
||||
export { TokenPrefix, isLogin, getToken, setToken, getCompanyId, setCompanyId, clearToken };
|
||||
export {
|
||||
TokenPrefix,
|
||||
isLogin,
|
||||
getToken,
|
||||
setToken,
|
||||
getSessionKey,
|
||||
setSessionKey,
|
||||
getOpenId,
|
||||
setOpenId,
|
||||
getCompanyId,
|
||||
setCompanyId,
|
||||
getReferrerUserId,
|
||||
setReferrerUserId,
|
||||
getRegisterStoreId,
|
||||
setRegisterStoreId,
|
||||
clearToken
|
||||
};
|
||||
|
@@ -1,5 +1,7 @@
|
||||
// 小程序更新检测
|
||||
|
||||
import { isLogin } from '@/utils';
|
||||
|
||||
export function mpUpdate() {
|
||||
const updateManager = uni.getUpdateManager();
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
@@ -50,18 +52,44 @@ export function showToast(title: string, { icon, duration, complete }: ToastOpti
|
||||
});
|
||||
}
|
||||
|
||||
export function goPath(path: string) {
|
||||
uni.navigateTo({
|
||||
url: path
|
||||
}).then(r => {
|
||||
});
|
||||
export function goPath(path: string, needAuth: boolean = false) {
|
||||
if(needAuth && !isLogin()) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您还未登录,请先登录',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm) {
|
||||
goLogin();
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(path.includes('home/index') || path.includes('mall/index') || path.includes('qrcode/index') || path.includes('mine/index')) {
|
||||
uni.switchTab({
|
||||
url: path
|
||||
}).then(r => {
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: path
|
||||
}).then(r => {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function goLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
}).then(r => {
|
||||
});
|
||||
export function goLogin(reLaunch: boolean = false) {
|
||||
const path = '/pages/common/login/index';
|
||||
if(reLaunch) {
|
||||
uni.reLaunch({
|
||||
url: path
|
||||
}).then();
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: path
|
||||
}).then();
|
||||
}
|
||||
}
|
||||
|
||||
export function formatTimeWithZeroPad(num: number): string {
|
||||
@@ -101,3 +129,18 @@ export function parseParameter(obj: any) {
|
||||
}
|
||||
return arr.join('&');
|
||||
}
|
||||
|
||||
export function copy(content: string) {
|
||||
uni.setClipboardData({
|
||||
data: content,
|
||||
success: function(res) {
|
||||
showToast('复制成功');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getQueryParam(queryParams: string, key: string) {
|
||||
let regex = new RegExp('(?:[?&]|^)' + key + '=([^&]+)'),
|
||||
match = queryParams.match(regex);
|
||||
return match && match[1];
|
||||
}
|
||||
|
36
src/utils/common/logger.ts
Normal file
36
src/utils/common/logger.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import RealtimeTagLogManager = UniNamespace.RealtimeTagLogManager;
|
||||
|
||||
export class Logger {
|
||||
|
||||
private env = uni.getAccountInfoSync().miniProgram.envVersion;
|
||||
private readonly logger: RealtimeTagLogManager;
|
||||
|
||||
constructor() {
|
||||
const logManager = uni.getRealtimeLogManager();
|
||||
this.logger = logManager.tag('suke-mp');
|
||||
}
|
||||
|
||||
info(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.info(key, value);
|
||||
} else {
|
||||
console.info(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
warn(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.warn(key, value);
|
||||
}else {
|
||||
console.warn(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
error(key: string, value: any) {
|
||||
if(this.env === 'release' || this.env === 'trial') {
|
||||
this.logger.error(key, value);
|
||||
}else {
|
||||
console.error(key, value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -34,8 +34,9 @@ export const handlePayResult = (orderId: string | undefined, e: any, { onSuccess
|
||||
const resultObj = JSON.parse(str.replaceAll('result=', ''));
|
||||
|
||||
if(resultObj?.is_success === true) {
|
||||
getApp().globalData?.logger?.info('pay success : ', orderId, resultObj);
|
||||
if(onSuccess) {
|
||||
onSuccess();
|
||||
onSuccess(resultObj);
|
||||
} else {
|
||||
showToast('支付成功', {
|
||||
icon: 'success',
|
||||
@@ -45,14 +46,23 @@ export const handlePayResult = (orderId: string | undefined, e: any, { onSuccess
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if(onFailure) {
|
||||
onFailure();
|
||||
getApp().globalData?.logger?.error('pay failure :', orderId, str, resultObj);
|
||||
let msg = '支付失败';
|
||||
if(resultObj) {
|
||||
msg = resultObj?.error_message || '支付失败';
|
||||
} else {
|
||||
msg = JSON.parse(str)?.error_message || '支付失败';
|
||||
}
|
||||
if(onFailure) {
|
||||
onFailure(msg);
|
||||
} else {
|
||||
showToast(msg, {
|
||||
complete: () => {
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
}
|
||||
const msg = resultObj?.error_message || '支付失败';
|
||||
showToast(msg, {
|
||||
complete: () => {
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import type { HttpError, HttpRequestConfig, HttpResponse } from 'uview-plus/libs/luch-request';
|
||||
import { showMessage } from './status';
|
||||
import { getCompanyId, getToken } from '@/utils/auth';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import { showMessage } from '@/utils/request/status';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
// 是否正在刷新token的标记
|
||||
let isRefreshing: boolean = false;
|
||||
@@ -26,6 +26,7 @@ function requestInterceptors() {
|
||||
|
||||
// config.header.contentType = "x-www-form-urlencoded"
|
||||
}
|
||||
// getApp().globalData?.logger.info('request: ', config);
|
||||
return config;
|
||||
},
|
||||
(
|
||||
@@ -52,18 +53,23 @@ function responseInterceptors() {
|
||||
return data;
|
||||
}
|
||||
|
||||
getApp().globalData?.logger.info(response.config.url, {
|
||||
'request': response.config,
|
||||
'response': data
|
||||
});
|
||||
|
||||
// 请求成功则返回结果
|
||||
if(data.code === 200 || data?.retcode == 0) {
|
||||
return data || {};
|
||||
}
|
||||
|
||||
// 登录状态失效,重新登录
|
||||
if(data.code === 401) {
|
||||
if(data?.code === 401 || data?.code === 4011 || data?.retcode === 4011) {
|
||||
// 是否在获取token中,防止重复获取
|
||||
if(!isRefreshing) {
|
||||
// 修改登录状态为true
|
||||
isRefreshing = true;
|
||||
await useUserStore().authLogin();
|
||||
await useUserStore().login();
|
||||
// 登录完成之后,开始执行队列请求
|
||||
requestQueue.forEach(cb => cb());
|
||||
// 重试完了清空这个队列
|
||||
@@ -83,7 +89,14 @@ function responseInterceptors() {
|
||||
|
||||
// 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示
|
||||
if(custom?.toast !== false) {
|
||||
uni.$u.toast(data.message || data.retinfo);
|
||||
if(data?.retinfo?.includes('未登录')
|
||||
|| data?.retinfo?.includes('未登陆')
|
||||
|| data.message?.includes('未登录')
|
||||
|| data.message?.includes('未登陆')) {
|
||||
getApp()?.globalData?.logger.error('未登录');
|
||||
} else {
|
||||
uni.$u.toast(data.message || data.retinfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果需要catch返回,则进行reject
|
||||
@@ -96,12 +109,15 @@ function responseInterceptors() {
|
||||
}
|
||||
},
|
||||
(response: HttpError) => {
|
||||
console.error('http error: ', response);
|
||||
/* 对响应错误做点什么 (statusCode !== 200)*/
|
||||
getApp().globalData?.logger.error('request error : ', response);
|
||||
if(response.statusCode) {
|
||||
// 请求已发出,但是不在2xx的范围
|
||||
showMessage(response.statusCode);
|
||||
uni.$u.toast(showMessage(response.statusCode));
|
||||
return Promise.reject(response.data);
|
||||
}
|
||||
showMessage('网络连接异常,请稍后再试!');
|
||||
uni.$u.toast('网络连接异常,请稍后再试!');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ export const showMessage = (status: number | string): string => {
|
||||
message = 'HTTP版本不受支持(505)';
|
||||
break;
|
||||
default:
|
||||
message = `连接出错(${status})!`;
|
||||
message = `操作失败(${status})!`;
|
||||
}
|
||||
return `${message},请检查网络或联系管理员!`;
|
||||
};
|
||||
|
@@ -28,10 +28,6 @@
|
||||
"types/**/*.d.ts",
|
||||
"types/**/*.ts"
|
||||
],
|
||||
"exclude": ["dist", "node_modules", "uni_modules"],
|
||||
// uni-app Component type prompt
|
||||
"vueCompilerOptions": {
|
||||
"nativeTags": ["block", "component", "template", "slot"]
|
||||
}
|
||||
"exclude": ["dist", "node_modules", "uni_modules"]
|
||||
}
|
||||
|
||||
|
2
types/components.d.ts
vendored
2
types/components.d.ts
vendored
@@ -7,10 +7,12 @@ export {}
|
||||
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
CompanyDialog: typeof import('./../src/components/company-dialog.vue')['default']
|
||||
OfficialAccountDialog: typeof import('./../src/components/official-account-dialog.vue')['default']
|
||||
PageNav: typeof import('./../src/components/page-nav/page-nav.vue')['default']
|
||||
PaymentButton: typeof import('./../src/components/payment-button.vue')['default']
|
||||
PaymentDialog: typeof import('./../src/components/payment-dialog.vue')['default']
|
||||
PayPasswordDialog: typeof import('./../src/components/pay-password-dialog.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
SkuDialog: typeof import('./../src/components/sku-dialog.vue')['default']
|
||||
|
Reference in New Issue
Block a user