Compare commits
33 Commits
b7461002dc
...
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 |
@@ -4,9 +4,10 @@ VITE_APP_TITLE='uniapp-vue3-project'
|
||||
# 开发环境配置
|
||||
VITE_APP_ENV='development'
|
||||
|
||||
VITE_APP_ID='wx92e663dc11d0c0a8'
|
||||
|
||||
# 接口地址
|
||||
VITE_APP_BASE_API='https://apidev.lakeapp.cn/'
|
||||
#VITE_APP_BASE_API='https://api.lakeapp.cn/'
|
||||
|
||||
# 删除console
|
||||
VITE_DROP_CONSOLE=false
|
||||
|
@@ -4,6 +4,8 @@ VITE_APP_TITLE='uniapp-vue3-project'
|
||||
# 生产环境配置
|
||||
VITE_APP_ENV='production'
|
||||
|
||||
VITE_APP_ID='wx67a750d0ceed4d88'
|
||||
|
||||
# 接口地址
|
||||
VITE_APP_BASE_API='https://api.lakeapp.cn/'
|
||||
|
||||
|
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
|
||||
|
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);
|
||||
}
|
||||
}
|
||||
});
|
30
package.json
30
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,10 +17,10 @@
|
||||
"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",
|
||||
@@ -29,11 +31,11 @@
|
||||
},
|
||||
"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",
|
||||
"@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",
|
||||
@@ -59,7 +61,7 @@
|
||||
"unocss-applet": "^0.7.8",
|
||||
"unplugin-auto-import": "^0.16.7",
|
||||
"unplugin-vue-components": "^0.25.2",
|
||||
"vite": "^4.5.3",
|
||||
"vite": "^5.2.8",
|
||||
"vite-plugin-imagemin": "^0.6.1",
|
||||
"vue-tsc": "^1.8.24"
|
||||
},
|
||||
|
2799
pnpm-lock.yaml
generated
2799
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
50
src/App.vue
50
src/App.vue
@@ -1,19 +1,27 @@
|
||||
<script lang='ts'>
|
||||
import { mpUpdate, setCompanyId, setReferrerUserId, setRegisterStoreId } from '@/utils';
|
||||
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) => {
|
||||
console.log('App Launch options ', options);
|
||||
|
||||
const miniProgram = uni.getAccountInfoSync().miniProgram;
|
||||
const env = miniProgram.envVersion;
|
||||
|
||||
console.log(`App Launch options ${env}: `, options);
|
||||
|
||||
//生产
|
||||
if(env === 'release' || env === 'trial') {
|
||||
logger.info(`launch options ${env}: `, options);
|
||||
if(env === 'release') {
|
||||
logger.info(`App Launch options ${env}: `, options);
|
||||
|
||||
async function getVersionStatus() {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -42,13 +50,20 @@ export default {
|
||||
|
||||
//测试、开发 trial,develop
|
||||
else {
|
||||
// setCompanyId('1724629180555919361');
|
||||
// setRegisterStoreId('1725026299888406529');
|
||||
// setCompanyId('1471673498334113794');
|
||||
// setRegisterStoreId('1471673498413805570');
|
||||
|
||||
//生产环境
|
||||
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) {
|
||||
@@ -71,12 +86,6 @@ export default {
|
||||
}
|
||||
|
||||
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')) {
|
||||
@@ -95,6 +104,8 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`App Launch options ${env}: { companyId: `, getCompanyId() + ', storeId: ' + getRegisterStoreId() + ' }');
|
||||
|
||||
// #ifdef MP
|
||||
mpUpdate();
|
||||
// #endif
|
||||
@@ -107,7 +118,12 @@ export default {
|
||||
},
|
||||
|
||||
globalData: {
|
||||
logger: logger
|
||||
logger: logger,
|
||||
companyId: getCompanyId(),
|
||||
storeId: getRegisterStoreId(),
|
||||
shareCompanyId: '',//分享过来的公司id
|
||||
shareStoreId: '',//分享过来的店铺id
|
||||
sharePath: ''//分享页面路径,方便登录后跳转
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -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 });
|
||||
|
@@ -13,13 +13,21 @@ export const getGroupBuyList = (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',
|
||||
@@ -32,7 +33,8 @@ enum URL {
|
||||
tradeList = '/memberIncoming/wx_balance_records',
|
||||
terminal = 'wechat/coupons/terminal?companyId=',
|
||||
cardLink = '/wc/wechat/get_card_url',
|
||||
registerCoupon = '/couponsStrategy/wx_register_coupon'
|
||||
registerCoupon = '/couponsStrategy/wx_register_coupon',
|
||||
setPayPassword = '/app/pay/set_paypwd',
|
||||
}
|
||||
|
||||
export const getUserProfile = () => get<UserBean>({ url: URL.profile });
|
||||
@@ -42,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 });
|
||||
@@ -73,3 +77,11 @@ 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
|
||||
});
|
||||
|
@@ -31,6 +31,7 @@ export interface LoginResult {
|
||||
user: UserBean;
|
||||
userInfo: any;
|
||||
token: string;
|
||||
maOpenId: string;
|
||||
}
|
||||
|
||||
export interface IntegralBean {
|
||||
@@ -117,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
|
||||
}
|
||||
|
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>
|
@@ -2,8 +2,8 @@
|
||||
"name": "SUKE-MP",
|
||||
"appid": "",
|
||||
"description": "",
|
||||
"versionName": "3.0.2",
|
||||
"versionCode": "302",
|
||||
"versionName": "3.0.4",
|
||||
"versionCode": "304",
|
||||
"transformPx": false,
|
||||
"app-plus": {
|
||||
"usingComponents": true,
|
||||
@@ -18,15 +18,14 @@
|
||||
"modules": {}
|
||||
},
|
||||
"mp-weixin": {
|
||||
// "appid": "wx92e663dc11d0c0a8",
|
||||
"appid": "wx67a750d0ceed4d88",
|
||||
"appid": "wx92e663dc11d0c0a8",
|
||||
"setting": {
|
||||
"urlCheck": false
|
||||
},
|
||||
"usingComponents": true,
|
||||
"plugins": {
|
||||
"sqb-pay": {
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"provider": "wx55540b288c5ce319"
|
||||
}
|
||||
}
|
||||
|
@@ -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": "团购详情"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -85,6 +92,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "groupbuy/order-coupon-confirm",
|
||||
"style": {
|
||||
"navigationBarTitleText": "确认订单",
|
||||
"usingComponents": {
|
||||
"sqb-pay": "plugin://sqb-pay/sqb-pay"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "webview/index",
|
||||
"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' mode='aspectFill'/>
|
||||
<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,7 +17,7 @@
|
||||
</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 v-if='isPending()' class='countdown-time c-flex-column'>
|
||||
<view class='c-flex-row'>{{ countdownTime?.days || 0 }}天
|
||||
@@ -51,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>
|
||||
@@ -77,13 +77,16 @@
|
||||
<!-- 商品详情图片 -->
|
||||
<view class='card-view image-container' v-if='groupBuyBean?.content'>
|
||||
<text class='card-view-title'>商品详情</text>
|
||||
<image
|
||||
<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'>
|
||||
@@ -101,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' />
|
||||
@@ -109,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'>
|
||||
@@ -139,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);
|
||||
@@ -155,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);
|
||||
@@ -169,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();
|
||||
if(e.id != undefined) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -189,13 +262,25 @@ 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 = () => {
|
||||
@@ -205,7 +290,7 @@ const isEnded = () => {
|
||||
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 () => {
|
||||
@@ -264,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,
|
||||
@@ -274,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))}`);
|
||||
}
|
||||
|
||||
if(isCouponGoodsDetail.value) {
|
||||
goPath(`/pages/common/groupbuy/order-coupon-confirm?bean=${encodeURIComponent(JSON.stringify(groupBuyBean.value))}`);
|
||||
} else {
|
||||
showSkuDialog((e: GoodsBean) => {
|
||||
create(e);
|
||||
createGoodsOrder(e);
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -604,6 +695,8 @@ const placeOrder = async () => {
|
||||
.goods-container {
|
||||
padding: 30rpx;
|
||||
position: relative;
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
|
||||
image {
|
||||
width: 200rpx;
|
||||
@@ -646,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;
|
||||
@@ -661,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;
|
||||
}
|
||||
}
|
||||
|
@@ -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' />
|
||||
@@ -57,8 +56,12 @@ 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(() => {
|
||||
@@ -66,10 +69,10 @@ const buildSqbParams = computed(() => {
|
||||
client_sn: orderBean.value?.id || '',
|
||||
return_url: '/pages/common/payresult/index',
|
||||
total_amount: Number(((orderBean.value?.totalPrice || 0) * 100).toFixed(2)),
|
||||
terminal_sn: terminalInfo.value.terminalSn,
|
||||
subject: '商品团购券',
|
||||
subject_img: orderBean?.value?.orderGoods[0].images || '',
|
||||
merchant_name: terminalInfo.value.companyName,
|
||||
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,7 +84,7 @@ const buildSqbParams = computed(() => {
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.id, e, {
|
||||
onSuccess: () => {
|
||||
onSuccess: (options: any) => {
|
||||
showToast('支付成功', {
|
||||
icon: 'success',
|
||||
complete: () => {
|
||||
@@ -94,11 +97,22 @@ const navigateTo = (e: any) => {
|
||||
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>
|
@@ -24,11 +24,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { getCompanyList } from '@/api/company';
|
||||
import { useUserStore } from '@/store';
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import { showToast } from '@/utils';
|
||||
import { getCompanyId, getOpenId, goPath, showToast } from '@/utils';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
const isAgreePrivacy = ref(false);
|
||||
|
||||
function wechatLogin() {
|
||||
@@ -36,10 +38,43 @@ function wechatLogin() {
|
||||
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();
|
||||
|
||||
//登录成功先判断当前公司有没有注册过
|
||||
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' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -1,228 +1,221 @@
|
||||
<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 class='c-flex-column avatar-container'>
|
||||
<image class='avatar' :src='avatarUrl' />
|
||||
<button class='avatar-button' open-type='chooseAvatar' @chooseavatar='chooseAvatar' />
|
||||
</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 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' />
|
||||
|
||||
<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 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 { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import { ref } from 'vue';
|
||||
import { getTelephone } from '@/api/user';
|
||||
import { useUserStore } from '@/store';
|
||||
import { goPath } from '@/utils';
|
||||
import { getRegisterCoupon } from '@/api/user';
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import { getRegisterStoreId, getSessionKey, showToast } from '@/utils';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { companyConfigInfo } = storeToRefs(userStore);
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
|
||||
const countdown = ref('获取验证码');
|
||||
const couponBean = ref();
|
||||
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);
|
||||
|
||||
onLoad(async (e) => {
|
||||
couponBean.value = await getRegisterCoupon();
|
||||
});
|
||||
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;
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const register = () => {
|
||||
};
|
||||
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'
|
||||
});
|
||||
}
|
||||
}
|
||||
uni.hideLoading();
|
||||
};
|
||||
</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;
|
||||
}
|
||||
background: white;
|
||||
padding: 30rpx;
|
||||
|
||||
.divider {
|
||||
border-bottom-style: dashed;
|
||||
border-color: #E98585;
|
||||
border-width: 0.2rpx;
|
||||
margin-top: 34rpx
|
||||
margin: 30rpx 5rpx;
|
||||
}
|
||||
|
||||
.coupon {
|
||||
margin-top: 30rpx;
|
||||
|
||||
.coupon-name {
|
||||
display: flex;
|
||||
font-size: 36rpx;
|
||||
color: #D95554;
|
||||
flex: 1;
|
||||
.row-title {
|
||||
font-size: 30rpx;
|
||||
color: #666666;
|
||||
width: 150rpx;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 13rpx;
|
||||
height: 24rpx;
|
||||
}
|
||||
|
||||
.expired-time {
|
||||
font-size: 28rpx;
|
||||
.row-value {
|
||||
font-size: 30rpx;
|
||||
color: #333333;
|
||||
margin-top: 2rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.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>
|
||||
|
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")'>
|
||||
<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")'>
|
||||
<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,12 +33,12 @@
|
||||
</view>
|
||||
|
||||
<view class='menu-view'>
|
||||
<view @click.stop='goPath("/pages/mine/subs/recharge/index")'>
|
||||
<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")'>
|
||||
<view @click.stop='goPath("/pages/mine/subs/coupon/index",true)'>
|
||||
<image :src='assetsUrl("ic_coupon2.png")' style='width: 108rpx;height: 95rpx' />
|
||||
<text>优惠券</text>
|
||||
</view>
|
||||
@@ -72,7 +72,7 @@ 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';
|
||||
|
||||
@@ -86,6 +86,11 @@ const submenuList = [
|
||||
title: '注册有礼',
|
||||
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: '团购秒杀',
|
||||
@@ -127,48 +132,104 @@ onLoad((e) => {
|
||||
onShow(async () => {
|
||||
if(isLogin()) {
|
||||
// userStore.getProfile();
|
||||
if(userInfo.value.maOpenId) {
|
||||
fetchCompanyList();
|
||||
} else {
|
||||
await userStore.getProfile();
|
||||
}
|
||||
} else {
|
||||
// setToken('42ae187265fb4688804fd294cbcf99f1')
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您还未登录,请先登录',
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if(res.confirm) {
|
||||
goPath('/pages/common/login/index');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const switchCompany = () => {
|
||||
fetchCompanyList((companyList: any[], userList: any[]) => {
|
||||
companyDialogRef.value.show(getCompanyId(),(index: number) => {
|
||||
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 = userInfo.value?.maOpenId || (userList.value.filter((res: UserBean) => res?.maOpenId !== '')[0]?.maOpenId);
|
||||
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 === getCompanyId());
|
||||
let index = companyList.value.findIndex((res: { id: string }) => res.id === getApp()?.globalData?.companyId);
|
||||
//未在当前公司下注册
|
||||
if(index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
userStore.setUserInfo(userList.value[index]);
|
||||
userStore.setCompanyInfo(companyList.value[index]);
|
||||
showRegisterModal();
|
||||
return;
|
||||
}
|
||||
|
||||
// uni.showActionSheet({
|
||||
// itemList: companyList.map((res: { companyName: string }) => res.companyName),
|
||||
// success: (res) => {
|
||||
// userStore.setUserInfo(userList[res.tapIndex]);
|
||||
// userStore.setCompanyInfo(companyList[res.tapIndex]);
|
||||
// }
|
||||
// });
|
||||
//分享过来的公司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');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@@ -3,10 +3,51 @@
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
onMounted(() => {
|
||||
|
||||
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>
|
||||
|
||||
|
@@ -50,7 +50,7 @@
|
||||
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';
|
||||
@@ -69,7 +69,6 @@ const currentPageNum = ref<number>(1);
|
||||
|
||||
onLoad(() => {
|
||||
if(!isLogin()) {
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -147,6 +147,13 @@ onLoad(async (e: any) => {
|
||||
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)!);
|
||||
|
@@ -49,7 +49,8 @@
|
||||
</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>
|
||||
@@ -160,16 +161,16 @@ const buildSqbParams = computed(() => {
|
||||
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: orderBean?.value?.orderGoods[0].name||'未知',
|
||||
subject_img: orderBean?.value?.orderGoods[0].images || '',
|
||||
merchant_name: terminalInfo.value.companyName,
|
||||
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,12 +188,12 @@ 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 = '';
|
||||
}
|
||||
@@ -202,7 +203,10 @@ const navigateTo = (e: any) => {
|
||||
};
|
||||
|
||||
const createOrder = async () => {
|
||||
|
||||
if(!terminalInfo.value) {
|
||||
showToast('当前店铺未配置收款渠道,请联系商家');
|
||||
return;
|
||||
}
|
||||
//邮寄
|
||||
if(tabIndex.value == 1 && !deliveryAddress.value.addrid) {
|
||||
showToast('请选择收货地址');
|
||||
|
@@ -59,8 +59,11 @@
|
||||
<text>{{ item.title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
<!-- 支付密码设置弹框 -->
|
||||
<pay-password-dialog ref="payPasswordDialogRef" />
|
||||
<official-account-dialog ref='officialAccountDialogRef' />
|
||||
</template>
|
||||
|
||||
@@ -71,10 +74,12 @@ 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: '未支付',
|
||||
@@ -114,6 +119,11 @@ const serviceList = [
|
||||
title: '联系商家',
|
||||
icon: assetsUrl('ic_member_service_contact.png'),
|
||||
path: '/pages/mine/subs/contact/index'
|
||||
},
|
||||
{
|
||||
title: '支付密码',
|
||||
icon: '/static/images/ic_member_pay_password.png',
|
||||
path: 'pay_password'
|
||||
}
|
||||
// ,{
|
||||
// title: '推广中心',
|
||||
@@ -129,13 +139,14 @@ 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,
|
||||
@@ -145,6 +156,7 @@ onShow(async () => {
|
||||
const { cardurl } = await getCardLink();
|
||||
cardLink.value = cardurl;
|
||||
await userStore.getProfile();
|
||||
}
|
||||
});
|
||||
|
||||
const openCard = () => {
|
||||
@@ -161,9 +173,19 @@ const openCard = () => {
|
||||
// });
|
||||
};
|
||||
|
||||
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'
|
||||
@@ -173,13 +195,9 @@ const gotoPath = (path: string) => {
|
||||
phoneNumber: companyInfo.value.telphone
|
||||
});
|
||||
} else {
|
||||
goPath(path);
|
||||
goPath(path, true);
|
||||
}
|
||||
};
|
||||
|
||||
const showOfficialAccountDialog = () => {
|
||||
officialAccountDialogRef.value.show();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
@@ -199,6 +217,7 @@ const showOfficialAccountDialog = () => {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
<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>有效期至{{ 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>
|
||||
@@ -80,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;
|
||||
|
@@ -178,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 || '');
|
||||
}
|
||||
});
|
||||
|
@@ -48,7 +48,7 @@
|
||||
<view class='c-flex-row'>
|
||||
<text>生日</text>
|
||||
<picker mode='date' :disabled='(userInfo.birthday?.length||0)!=0' @change='changeDate'>
|
||||
<text>{{ params?.birthday || '请选择生日' }}</text>
|
||||
<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,7 +135,7 @@ 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
|
||||
});
|
||||
|
||||
|
@@ -120,7 +120,7 @@ const buildSqbParams = computed(() => {
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(preRechargeOrderId.value, e, {
|
||||
onSuccess: async () => {
|
||||
onSuccess: async (options: any) => {
|
||||
await goRecharge();
|
||||
await userState.setUserInfo({
|
||||
...userInfo.value,
|
||||
@@ -128,7 +128,7 @@ const navigateTo = (e: any) => {
|
||||
});
|
||||
await uni.navigateBack();
|
||||
},
|
||||
onFailure: () => {
|
||||
onFailure: (e: any) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@@ -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>
|
@@ -25,11 +25,12 @@ list.forEach((item) => {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (checkWhite(to.url))
|
||||
// if (checkWhite(to.url))
|
||||
// return true;
|
||||
//
|
||||
// uni.reLaunch({ url: loginPage });
|
||||
// return false;
|
||||
return true;
|
||||
|
||||
uni.reLaunch({ url: loginPage });
|
||||
return false;
|
||||
}
|
||||
},
|
||||
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_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 |
@@ -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;
|
||||
}
|
||||
}
|
@@ -12,11 +12,11 @@ const useShoppingCartStore = defineStore('shoppingCart', {
|
||||
key: 'shoppingCartState',
|
||||
storage: {
|
||||
setItem(key, value) {
|
||||
uni.setStorageSync(key, value || []); // [!code warning]
|
||||
uni.setStorageSync(key, value); // [!code warning]
|
||||
uni.setStorageSync(`shoppingCart_${getCompanyId()}`, JSON.parse(value).shoppingCartList);
|
||||
},
|
||||
getItem(key) {
|
||||
return uni.getStorageSync(uni.getStorageSync(`shoppingCart_${getCompanyId()}`)) || []; // [!code warning]
|
||||
return uni.getStorageSync(uni.getStorageSync(`shoppingCart_${getCompanyId()}`)) || '';
|
||||
}
|
||||
},
|
||||
// 部分持久化状态的点符号路径数组,[]意味着没有状态被持久化(默认为undefined,持久化整个状态)
|
||||
@@ -33,12 +33,19 @@ const useShoppingCartStore = defineStore('shoppingCart', {
|
||||
},
|
||||
|
||||
getSameGoodsIndex: (state) => (goodsId: string, colorId: string, sizeId: string) => {
|
||||
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);
|
||||
},
|
||||
|
||||
|
@@ -1,9 +1,18 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import type { providerType, UserBean } from './types';
|
||||
import { getTerminal, getUserProfile, login, logout as userLogout, register } from '@/api/user/index';
|
||||
import { clearToken, getRegisterStoreId, 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: () => ({
|
||||
@@ -28,7 +37,7 @@ const useUserStore = defineStore('user', {
|
||||
mobile: '',
|
||||
addr: '',
|
||||
defaultstatus: 0
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
persist: {
|
||||
@@ -47,10 +56,6 @@ const useUserStore = defineStore('user', {
|
||||
},
|
||||
|
||||
getters: {
|
||||
// getUserInfo(state: UserBean): UserBean {
|
||||
// return { state };
|
||||
// }
|
||||
|
||||
getUserDiscount(): number {
|
||||
if(this.userInfo?.levelEntity?.discount > 0 && this.userInfo?.levelEntity?.discount < 10) {
|
||||
return this.userInfo?.levelEntity?.discount / 10;
|
||||
@@ -66,68 +71,7 @@ const useUserStore = defineStore('user', {
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 设置用户的信息
|
||||
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);
|
||||
} else {
|
||||
await clearToken();
|
||||
}
|
||||
await this.fetchTerminal();
|
||||
await this.fetchCompanyInfo();
|
||||
},
|
||||
|
||||
setCompanyInfo(partial: Partial<any>) {
|
||||
this.companyInfo = partial as any;
|
||||
},
|
||||
|
||||
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();
|
||||
},
|
||||
|
||||
checkUserRegisterStatus() {
|
||||
|
||||
},
|
||||
|
||||
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,
|
||||
@@ -150,32 +94,15 @@ const useUserStore = defineStore('user', {
|
||||
// referrerUserId: getReferrerUserId()
|
||||
});
|
||||
getApp().globalData?.logger.info('login result: ', res);
|
||||
|
||||
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,
|
||||
storeId: getRegisterStoreId()
|
||||
};
|
||||
getApp().globalData?.logger.info('register params: ', registerForm);
|
||||
const registerResult = await this.userRegister(registerForm);
|
||||
getApp().globalData?.logger.info('register result: ', registerResult);
|
||||
if(registerResult != null) {
|
||||
setToken(res.token);
|
||||
await this.setUserInfo(registerResult as LoginResult);
|
||||
}
|
||||
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);
|
||||
@@ -191,9 +118,97 @@ const useUserStore = defineStore('user', {
|
||||
});
|
||||
},
|
||||
|
||||
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
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -9,6 +9,7 @@ export interface UserBean {
|
||||
birthdayType: number;
|
||||
card: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
consumption: string;
|
||||
consumptionDay: string;
|
||||
couponsCount: number;
|
||||
@@ -42,6 +43,7 @@ export interface UserBean {
|
||||
source: string;
|
||||
status: string;
|
||||
storeId: string;
|
||||
storeName: string;
|
||||
telephone: string;
|
||||
totalConsumption: string;
|
||||
totalIncoming: number;
|
||||
@@ -50,7 +52,8 @@ export interface UserBean {
|
||||
updateTime: string;
|
||||
useCouponsPrice: number;
|
||||
wirelinedTelephone: string;
|
||||
userDiscount:number
|
||||
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,4 +1,6 @@
|
||||
const TokenKey = 'accessToken';
|
||||
const SessionKey = 'sessionKey';
|
||||
const OpenIdKey = 'openId';
|
||||
const CompanyIdKey = 'companyId';
|
||||
const ReferrerUserIdKey = 'referrerUserId';
|
||||
const RegisterStoreIdKey = 'storeId';
|
||||
@@ -17,12 +19,33 @@ 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) {
|
||||
if(companyId) {
|
||||
uni.setStorageSync(CompanyIdKey, companyId);
|
||||
if(getApp()?.globalData) {
|
||||
getApp().globalData!.companyId = companyId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getReferrerUserId() {
|
||||
@@ -44,6 +67,7 @@ function getRegisterStoreId() {
|
||||
function clearToken() {
|
||||
uni.removeStorageSync(TokenKey);
|
||||
uni.removeStorageSync(CompanyIdKey);
|
||||
uni.removeStorageSync(SessionKey);
|
||||
}
|
||||
|
||||
export {
|
||||
@@ -51,6 +75,10 @@ export {
|
||||
isLogin,
|
||||
getToken,
|
||||
setToken,
|
||||
getSessionKey,
|
||||
setSessionKey,
|
||||
getOpenId,
|
||||
setOpenId,
|
||||
getCompanyId,
|
||||
setCompanyId,
|
||||
getReferrerUserId,
|
||||
|
@@ -1,5 +1,7 @@
|
||||
// 小程序更新检测
|
||||
|
||||
import { isLogin } from '@/utils';
|
||||
|
||||
export function mpUpdate() {
|
||||
const updateManager = uni.getUpdateManager();
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
@@ -50,7 +52,20 @@ export function showToast(title: string, { icon, duration, complete }: ToastOpti
|
||||
});
|
||||
}
|
||||
|
||||
export function goPath(path: string) {
|
||||
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
|
||||
@@ -64,11 +79,17 @@ export function goPath(path: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export function goLogin() {
|
||||
export function goLogin(reLaunch: boolean = false) {
|
||||
const path = '/pages/common/login/index';
|
||||
if(reLaunch) {
|
||||
uni.reLaunch({
|
||||
url: path
|
||||
}).then();
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
}).then(r => {
|
||||
});
|
||||
url: path
|
||||
}).then();
|
||||
}
|
||||
}
|
||||
|
||||
export function formatTimeWithZeroPad(num: number): string {
|
||||
@@ -117,3 +138,9 @@ export function copy(content: string) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getQueryParam(queryParams: string, key: string) {
|
||||
let regex = new RegExp('(?:[?&]|^)' + key + '=([^&]+)'),
|
||||
match = queryParams.match(regex);
|
||||
return match && match[1];
|
||||
}
|
||||
|
@@ -13,18 +13,24 @@ export class Logger {
|
||||
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 || '支付失败';
|
||||
}
|
||||
const msg = resultObj?.error_message || '支付失败';
|
||||
if(onFailure) {
|
||||
onFailure(msg);
|
||||
} else {
|
||||
showToast(msg, {
|
||||
complete: () => {
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -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,7 +26,7 @@ function requestInterceptors() {
|
||||
|
||||
// config.header.contentType = "x-www-form-urlencoded"
|
||||
}
|
||||
getApp().globalData?.logger.info('request: ', config);
|
||||
// getApp().globalData?.logger.info('request: ', config);
|
||||
return config;
|
||||
},
|
||||
(
|
||||
@@ -53,7 +53,10 @@ function responseInterceptors() {
|
||||
return data;
|
||||
}
|
||||
|
||||
getApp().globalData?.logger.info('response: ', config);
|
||||
getApp().globalData?.logger.info(response.config.url, {
|
||||
'request': response.config,
|
||||
'response': data
|
||||
});
|
||||
|
||||
// 请求成功则返回结果
|
||||
if(data.code === 200 || data?.retcode == 0) {
|
||||
@@ -61,12 +64,12 @@ function responseInterceptors() {
|
||||
}
|
||||
|
||||
// 登录状态失效,重新登录
|
||||
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());
|
||||
// 重试完了清空这个队列
|
||||
@@ -86,8 +89,15 @@ function responseInterceptors() {
|
||||
|
||||
// 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示
|
||||
if(custom?.toast !== false) {
|
||||
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
|
||||
if(custom?.catch) {
|
||||
@@ -99,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"]
|
||||
}
|
||||
|
||||
|
1
types/components.d.ts
vendored
1
types/components.d.ts
vendored
@@ -12,6 +12,7 @@ declare module 'vue' {
|
||||
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