feata:微信安全测试

This commit is contained in:
2026-07-24 21:05:21 +08:00
parent 73a7da4804
commit 3eba959b48
6 changed files with 209 additions and 68 deletions
+12
View File
@@ -195,6 +195,18 @@
"router" : { "router" : {
"mode" : "hash", "mode" : "hash",
"base" : "" "base" : ""
},
"devServer" : {
"port" : 5173,
"proxy" : {
"/proxy-api" : {
"target" : "https://api.o.tbmall.xin",
"changeOrigin" : true,
"pathRewrite" : {
"^/proxy-api" : ""
}
}
}
} }
} }
} }
+1 -1
View File
@@ -772,7 +772,7 @@ export default {
left: 0; left: 0;
right: 0; right: 0;
height: 4px; height: 4px;
background: linear-gradient(270deg, #af39c4 0%, #7732ff 100%); //background: linear-gradient(270deg, #af39c4 0%, #7732ff 100%);
pointer-events: none; pointer-events: none;
} }
} }
@@ -216,14 +216,14 @@
{{ selectSpecificationTempl.price }} {{ selectSpecificationTempl.price }}
</text> </text>
<view style="font-size: 50rpx" v-else> <view style="font-size: 50rpx" v-else>
{{ skuBySpecInfo.supplyPrice }} {{ skuBySpecInfo.originalPrice }}
<text v-if="skuBySpecInfo.price">- {{ skuBySpecInfo.price }}</text> <text v-if="skuBySpecInfo.price">- {{ skuBySpecInfo.price }}</text>
</view> </view>
<view class="price_content_coupon_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0"> <view class="price_content_coupon_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">
优惠券{{ 优惠券{{
orderInfo.couponPrice }}</view> orderInfo.couponPrice }}</view>
</view> </view>
<view class="oOrice_content_warp" v-if="!isCoupon">¥{{ skuBySpecInfo.supplyPrice }}</view> <view class="oOrice_content_warp" v-if="!isCoupon">¥{{ skuBySpecInfo.originalPrice }}</view>
<view class="coupon_content_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0"> <view class="coupon_content_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">
优惠券已优惠¥{{ 优惠券已优惠¥{{
orderInfo.couponPrice }}</view> orderInfo.couponPrice }}</view>
@@ -1224,7 +1224,7 @@ export default {
const skuBySpecBash = this.getSkuBySpecValueIds(this.selectedSpecValueIds) || {}; const skuBySpecBash = this.getSkuBySpecValueIds(this.selectedSpecValueIds) || {};
console.log("----111", skuBySpecBash) console.log("----111", skuBySpecBash)
this.skuBySpecInfo = { ...this.orderInfo, skuImage: skuBySpecBash.skuImage, stock: skuBySpecBash.stock, supplyPrice: skuBySpecBash.supplyPrice, price: skuBySpecBash.price, skuName: skuBySpecBash.skuName } this.skuBySpecInfo = { ...this.orderInfo, skuImage: skuBySpecBash.skuImage, stock: skuBySpecBash.stock, supplyPrice: skuBySpecBash.supplyPrice, price: skuBySpecBash.price, skuName: skuBySpecBash.skuName, originalPrice: skuBySpecBash.originalPrice }
console.log("----222", this.orderInfo) console.log("----222", this.orderInfo)
if (this.selectedSpecValueIds.every((id) => id != null)) { if (this.selectedSpecValueIds.every((id) => id != null)) {
+112 -9
View File
@@ -4,10 +4,8 @@
<Header title="设置" /> <Header title="设置" />
<view class="setting-view"> <view class="setting-view">
<view class="item-list mt-24"> <view class="item-list mt-24">
<view class="flex-r-lr item-box" @click="onHead(index)" <view class="flex-r-lr item-box" @click="onHead(index)" v-for="(item, index) in headList" :key="index"
v-for="(item,index) in headList" :key="index" :style="{ borderWidth: index == headList.length - 1 ? '0' : '2rpx' }">
:style="{borderWidth:index == headList.length - 1 ? '0' : '2rpx'}"
>
<text class="text-gray text-32">{{ item.text }}</text> <text class="text-gray text-32">{{ item.text }}</text>
<view class="flex-r-e" style="align-items: center;"> <view class="flex-r-e" style="align-items: center;">
<image v-if="item.type == 'img'" :src="item.value" class="ava-img"></image> <image v-if="item.type == 'img'" :src="item.value" class="ava-img"></image>
@@ -18,10 +16,8 @@
</view> </view>
<view class="item-list mt-24"> <view class="item-list mt-24">
<view class="flex-r-lr item-box" @click="onBottom(index)" <view class="flex-r-lr item-box" @click="onBottom(index)" v-for="(item, index) in bottomList"
v-for="(item,index) in bottomList" :key="index" :key="index" :style="{ borderWidth: index == bottomList.length - 1 ? '0' : '2rpx' }">
:style="{borderWidth:index == bottomList.length - 1 ? '0' : '2rpx'}"
>
<text class="text-gray text-32">{{ item.text }}</text> <text class="text-gray text-32">{{ item.text }}</text>
<view class="flex-r-e" style="align-items: center;"> <view class="flex-r-e" style="align-items: center;">
<u-icon size="16" name="arrow-right" color="#666" style="margin-left:12rpx"></u-icon> <u-icon size="16" name="arrow-right" color="#666" style="margin-left:12rpx"></u-icon>
@@ -118,7 +114,13 @@ export default {
success: (uploadFileRes) => { success: (uploadFileRes) => {
const data = JSON.parse(uploadFileRes.data); const data = JSON.parse(uploadFileRes.data);
if (data.bizcode === 100) { if (data.bizcode === 100) {
that.setUploadAvatar(data.data.accessUrl); const accessUrl = data.data.accessUrl;
// #ifdef MP-WEIXIN
that.handleWxMediaCheck(accessUrl);
// #endif
// #ifndef MP-WEIXIN
that.setUploadAvatar(accessUrl);
// #endif
} else { } else {
uni.showToast({ uni.showToast({
title: '图片上传失败', title: '图片上传失败',
@@ -142,10 +144,108 @@ export default {
} }
}); });
}, },
// #ifdef MP-WEIXIN
async handleWxMediaCheck(imgUrl) {
uni.showLoading({
title: '安全检测中...',
});
try {
const [token, openid] = await Promise.all([
this.getWxAccessToken(),
this.getWxOpenId()
]);
uni.request({
url: `https://api.weixin.qq.com/wxa/media_check_async?access_token=${token}`,
method: 'POST',
data: {
media_url: imgUrl,
media_type: 2,
version: 2,
scene: 1,
openid: openid
},
success: (res) => {
uni.hideLoading();
if (res.data && res.data.errcode === 0) {
this.setUploadAvatar(imgUrl);
} else {
uni.showToast({
title: (res.data && res.data.errmsg) || '图片检测未通过',
icon: 'none',
duration: 3000
});
}
},
fail: (err) => {
uni.hideLoading();
uni.showToast({
title: '安全检测失败',
icon: 'none',
duration: 3000
});
}
});
} catch (err) {
uni.hideLoading();
uni.showToast({
title: '获取微信凭证或OpenID失败',
icon: 'none',
duration: 3000
});
}
},
getWxAccessToken() {
const appid = 'wx376a16a88befe265';
const secret = '0e8fcbf770d72d41b84ea5ebdc427d10';
return new Promise((resolve, reject) => {
uni.request({
url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appid}&secret=${secret}`,
method: 'GET',
success: (res) => {
if (res.data && res.data.access_token) {
resolve(res.data.access_token);
} else {
reject(res.data);
}
},
fail: (err) => reject(err)
});
});
},
getWxOpenId() {
const appid = 'wx376a16a88befe265';
const secret = '0e8fcbf770d72d41b84ea5ebdc427d10';
return new Promise((resolve, reject) => {
uni.login({
provider: 'weixin',
success: (loginRes) => {
if (loginRes.code) {
uni.request({
url: `https://api.weixin.qq.com/sns/jscode2session?appid=${appid}&secret=${secret}&js_code=${loginRes.code}&grant_type=authorization_code`,
method: 'GET',
success: (res) => {
if (res.data && res.data.openid) {
resolve(res.data.openid);
} else {
reject(res.data);
}
},
fail: (err) => reject(err)
});
} else {
reject(loginRes);
}
},
fail: (err) => reject(err)
});
});
},
// #endif
setUploadAvatar(img) { setUploadAvatar(img) {
let params = { let params = {
imgUrl: img imgUrl: img
} }
console.log("---", params)
uploadAvatar(params).then(res => { uploadAvatar(params).then(res => {
if (res.bizcode === 100) { if (res.bizcode === 100) {
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
@@ -223,18 +323,21 @@ export default {
overflow-y: auto; overflow-y: auto;
padding: 0 32rpx; padding: 0 32rpx;
box-sizing: border-box; box-sizing: border-box;
.item-list { .item-list {
width: 100%; width: 100%;
border-radius: 16rpx; border-radius: 16rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background-color: #fff; background-color: #fff;
.item-box { .item-box {
min-height: 108rpx; min-height: 108rpx;
padding: 0 32rpx; padding: 0 32rpx;
box-sizing: border-box; box-sizing: border-box;
align-items: center; align-items: center;
border-bottom: solid #EAEAEA; border-bottom: solid #EAEAEA;
.ava-img { .ava-img {
width: 60rpx; width: 60rpx;
height: 60rpx; height: 60rpx;
+11 -1
View File
@@ -2,10 +2,20 @@ export const BASE_URL = "https://api.tbmall.xin"; //生产
export const MILD_BASE_URL = "https://agent.tbmall.xin/"; //中台生产 export const MILD_BASE_URL = "https://agent.tbmall.xin/"; //中台生产
export const kefuBaseUrl = "https://admin.tbmall.xin/api"; export const kefuBaseUrl = "https://admin.tbmall.xin/api";
// export const BASE_URL ='https://api.o.tbmall.xin'; // 本地测试
// export const BASE_URL = baseUrl; // 本地测试
// export const MILD_BASE_URL = "https://agent.o.tbmall.xin/"; //中台测试 // export const MILD_BASE_URL = "https://agent.o.tbmall.xin/"; //中台测试
// export const kefuBaseUrl = "https://admin.o.tbmall.xin/api"; // export const kefuBaseUrl = "https://admin.o.tbmall.xin/api";
// H5 环境且开发模式下使用 '/proxy-api' 代理解决浏览器跨域(注意不能用 '/api',否则会与本地 /api 源码目录冲突)
let baseUrl = 'https://api.o.tbmall.xin';
// #ifdef H5
if (process.env.NODE_ENV === 'development') {
baseUrl = '/proxy-api';
}
// #endif
// https://h.o.tbmall.xin/#/ // https://h.o.tbmall.xin/#/
// 客服接口属于管理后台服务,用户端接口已在后端单独放行。 // 客服接口属于管理后台服务,用户端接口已在后端单独放行。
+16
View File
@@ -0,0 +1,16 @@
import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
export default defineConfig({
plugins: [uni()],
server: {
port: 5173,
proxy: {
'/proxy-api': {
target: 'https://api.o.tbmall.xin',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy-api/, '')
}
}
}
});