Compare commits

..

6 Commits

Author SHA1 Message Date
Zhukj
fe3d00c653 feat:英文状态下,详情页客服新增点击跳转到客服会话页面功能 2025-12-19 17:54:23 +08:00
Zhukj
5c7daab504 feat:根据logo修改悬浮图标配色 2025-12-19 15:38:50 +08:00
Zhukj
e77bdc0359 feat:添加中英文切换按钮 2025-12-19 14:20:58 +08:00
Zhukj
5b37e00b98 feat:添加按钮显示 + 触发切换逻辑 2025-12-18 17:03:40 +08:00
Zhukj
123daa600c feat:数码喷墨墨水项目初始化 2025-12-18 15:26:29 +08:00
1854a85394 chore: update comments 2025-11-28 17:38:35 +08:00
19 changed files with 647 additions and 364 deletions

29
App.vue
View File

@@ -4,6 +4,8 @@
import { import {
Weixin Weixin
} from 'common/js/wx-jssdk.js'; } from 'common/js/wx-jssdk.js';
// 新增:引入多语言核心工具类
import langConfig from '@/common/js/lang.js';
export default { export default {
mixins: [auth], mixins: [auth],
@@ -15,6 +17,9 @@
} }
uni.hideTabBar(); uni.hideTabBar();
// 新增:应用启动时初始化多语言(核心修改)
this.initLang();
// #ifdef MP // #ifdef MP
const updateManager = uni.getUpdateManager(); const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) { updateManager.onCheckForUpdate(function(res) {
@@ -23,8 +28,8 @@
updateManager.onUpdateReady(function(res) { updateManager.onUpdateReady(function(res) {
uni.showModal({ uni.showModal({
title: '更新提示', title: langConfig.lang('common.updateTip'), // 新增:多语言标题
content: '新版本已经准备好,是否重启应用?', content: langConfig.lang('common.updateContent'), // 新增:多语言内容
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
@@ -48,8 +53,8 @@
uni.onNetworkStatusChange(function(res) { uni.onNetworkStatusChange(function(res) {
if (!res.isConnected) { if (!res.isConnected) {
uni.showModal({ uni.showModal({
title: '网络失去链接', title: langConfig.lang('common.networkTip'), // 新增:多语言标题
content: '请检查网络链接', content: langConfig.lang('common.networkContent'), // 新增:多语言内容
showCancel: false showCancel: false
}); });
} }
@@ -144,6 +149,9 @@
// #endif // #endif
}, },
onShow: function(options) { onShow: function(options) {
// 新增:应用前台显示时刷新多语言(确保切后台后语言仍生效)
langConfig.refresh();
// #ifdef MP // #ifdef MP
// 自动授权登录 // 自动授权登录
this.getAuthInfo(); this.getAuthInfo();
@@ -165,6 +173,19 @@
}, },
onHide: function() {}, onHide: function() {},
methods: { methods: {
// 新增:多语言初始化方法
initLang() {
// 1. 读取本地存储的语言,无则默认中文
const currentLang = uni.getStorageSync('lang') || 'zh-cn';
// 2. 初始化lang.js的locale变量确保全局语言一致
langConfig.locale = currentLang;
// 3. 刷新多语言配置标题、tabBar等
langConfig.refresh();
// 4. 挂载全局多语言方法(方便所有页面直接调用)
uni.$lang = langConfig.lang;
// 5. 挂载全局语言切换方法(可选,方便全局调用)
uni.$switchLang = langConfig.change;
},
/** /**
* 获取授权信息 * 获取授权信息
*/ */

View File

@@ -14,16 +14,16 @@ try {
// 调试版本,配置说明 // 调试版本,配置说明
const devCfg = { const devCfg = {
// 商户ID // 商户ID
uniacid: 460, //825 uniacid: 2285, //825
//api请求地址 //api请求地址
baseUrl: 'https://xcx30.5g-quickapp.com/', baseUrl: 'https://xcx.aigc-quickapp.com/',
// 图片域名 // 图片域名
imgDomain: 'https://xcx30.5g-quickapp.com/', imgDomain: 'https://xcx.aigc-quickapp.com/',
// H5端域名 // H5端域名
h5Domain: 'https://xcx30.5g-quickapp.com/', h5Domain: 'https://xcx.aigc-quickapp.com/',
// // api请求地址 // // api请求地址
// baseUrl: 'https://tsaas.liveplatform.cn/', // baseUrl: 'https://tsaas.liveplatform.cn/',

View File

@@ -1,128 +1,135 @@
const langList = ['zh-cn', 'en-us']; const langList = ['zh-cn', 'en-us'];
var locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言 var locale = uni.getStorageSync('lang') || "zh-cn"; // 设置默认语言
export default { export default {
langList: ['zh-cn', 'en-us'], langList: ['zh-cn', 'en-us'],
/** /**
* * 解析多语言 * 解析多语言
* @param {Object} field * @param {String} field 语言包字段(如 'common.title'
* @returns {String} 对应语言的文字
*/ */
lang(field) { lang(field) {
let _this = getCurrentPages()[getCurrentPages().length - 1]; let _this = getCurrentPages()[getCurrentPages().length - 1];
if (!_this) return; if (!_this) return field; // 无页面时返回原字段避免undefined
var value = ''; var value = field; // 默认返回原字段,防止空白
let newRoute; let newRoute;
try { try {
//公共语言包 // 1. 加载公共语言包(核心,兜底)
var lang = require('../../lang/' + locale + '/common.js').lang; var commonLang = require('../../lang/' + locale + '/common.js').lang;
// 2. 加载当前页面语言包(可选,失败不影响)
//当前页面语言包
let route = _this.route.split("/"); let route = _this.route.split("/");
newRoute = route.slice(1, route.length); newRoute = route.slice(1, route.length);
let currentPageLang = require('../../lang/' + locale + '/' + newRoute.join("/") + '.js').lang; let currentPageLang = {};
// 容错:页面语言包不存在时不报错
for (let f in currentPageLang) { try {
lang[f] = currentPageLang[f]; currentPageLang = require('../../lang/' + locale + '/' + newRoute.join("/") + '.js').lang;
} catch (e) {
console.warn(`当前页面(${newRoute.join("/")})无${locale}语言包`);
} }
// 合并:页面语言包覆盖公共语言包
var lang = { ...commonLang, ...currentPageLang };
// 解析字段(支持多级,如 'common.langSwitchBtn'
var arr = field.split("."); var arr = field.split(".");
if (arr.length > 1) { if (arr.length > 1) {
for (let i in arr) { value = lang; // 初始化为完整语言包
var next = parseInt(i) + 1; for (let i = 0; i < arr.length; i++) {
if (next < arr.length) { if (!value[arr[i]]) break; // 字段不存在时终止,避免报错
value = lang[arr[i]][arr[next]]; value = value[arr[i]];
}
} }
} else { } else {
value = lang[field]; value = lang[field] || field; // 字段不存在返回原字段
} }
} catch (e) { } catch (e) {
if (field.indexOf("common.") != -1 || field.indexOf("tabBar.") != -1) { console.error("语言包解析失败:", e);
value = lang[field]; value = field; // 兜底:返回原字段,避免空白
} else {
value = field;
}
} }
// 替换参数(如 'hello {0}' → 'hello 世界'
if (arguments.length > 1) { if (arguments.length > 1) {
//有参数,需要替换
for (var i = 1; i < arguments.length; i++) { for (var i = 1; i < arguments.length; i++) {
value = value.replace("{" + (i - 1) + "}", arguments[i]); value = value.replace("{" + (i - 1) + "}", arguments[i] || "");
} }
} }
if (value == undefined || (value == 'title' && field == 'title')) value = ''; // field // 最终兜底避免返回undefined/空字符串
return value; return value || field;
}, },
//切换语言 // 切换语言(核心修复:防白屏+全局事件)
change(value) { change(value) {
let _this = getCurrentPages()[getCurrentPages().length - 1]; // 1. 校验语言值合法性
if (!_this) return; if (!langList.includes(value)) {
console.error("语言值不合法:", value);
return;
}
// 2. 保存语言到本地存储
uni.setStorageSync("lang", value); uni.setStorageSync("lang", value);
locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言 locale = value; // 更新全局locale立即生效
// 3. 刷新标题/tabBar保留原有逻辑
this.refresh(); this.refresh();
// 4. 触发全局语言切换事件(通知所有页面/组件更新)
uni.reLaunch({ uni.$emit('lang-changed', value);
url: '/pages/member/index' // 5. 修复白屏:延迟重启当前页面(而非固定会员页)
}); setTimeout(() => {
let currentPage = getCurrentPages()[getCurrentPages().length - 1];
if (currentPage) {
uni.reLaunch({
url: '/' + currentPage.route // 重启当前页面,而非固定会员页
});
} else {
uni.reLaunch({ url: '/pages/index/index' }); // 兜底:重启首页
}
}, 300); // 300ms延迟确保语言配置加载完成避免白屏
}, },
//刷新标题、tabbar // 刷新标题、tabbar(优化:容错+强制生效)
refresh() { refresh() {
let _this = getCurrentPages()[getCurrentPages().length - 1]; let _this = getCurrentPages()[getCurrentPages().length - 1];
if (!_this) return; if (!_this) return;
locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言 locale = uni.getStorageSync('lang') || "zh-cn"; // 重新读取,确保最新
this.title(this.lang("title")); // 刷新导航栏标题(容错:标题字段不存在时不报错)
let titleText = this.lang("title") || "";
this.title(titleText);
//设置tabbar文字语言 // 修复:启用tabBar文字更新原代码被注释导致tabBar语言不切换
// uni.setTabBarItem({ try {
// index: 0, uni.setTabBarItem({ index: 0, text: this.lang("tabBar.home") || "首页" });
// text: this.lang("tabBar.home") uni.setTabBarItem({ index: 1, text: this.lang("tabBar.category") || "分类" });
// }); uni.setTabBarItem({ index: 2, text: this.lang("tabBar.cart") || "购物车" });
// uni.setTabBarItem({ uni.setTabBarItem({ index: 3, text: this.lang("tabBar.member") || "我的" });
// index: 1, } catch (e) {
// text: this.lang("tabBar.category") console.warn("tabBar文字更新失败", e);
// }); }
// uni.setTabBarItem({
// index: 2,
// text: this.lang("tabBar.cart")
// });
// uni.setTabBarItem({
// index: 3,
// text: this.lang("tabBar.member")
// });
}, },
// 设置导航栏标题(优化:容错)
title(str) { title(str) {
if (str) { if (str && typeof str === 'string') {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: str, title: str,
success: function (res) {
},
fail: function (err) { fail: function (err) {
console.warn("导航栏标题设置失败:", err);
} }
}); });
} }
}, },
// 获取语言包列表 // 获取语言包列表(优化:容错)
list() { list() {
var list = []; var list = [];
try { try {
//公共语言包
for (var i = 0; i < langList.length; i++) { for (var i = 0; i < langList.length; i++) {
let item = require('../../lang/' + langList[i] + '/common.js').lang; let langPath = '../../lang/' + langList[i] + '/common.js';
let item = require(langPath).lang;
list.push({ list.push({
name: item.common.name, name: item.common.name || langList[i], // 兜底:显示语言值
value: langList[i] value: langList[i]
}); });
} }
} catch (e) { } catch (e) {
// "没有找到语言包:", '../../lang/' + locale + '/common.js' console.error("获取语言包列表失败:", e);
// 兜底:返回基础列表
list = langList.map(item => ({ name: item, value: item }));
} }
return list; return list;
} }

View File

@@ -35,7 +35,7 @@
</template> </template>
<script> <script>
// //
export default { export default {
name: 'diy-audio', name: 'diy-audio',
props: { props: {

View File

@@ -223,6 +223,7 @@
</template> </template>
<script> <script>
// 组件组
export default { export default {
components: {}, components: {},
props: { props: {

View File

@@ -181,6 +181,7 @@
</template> </template>
<script> <script>
// 秒杀
export default { export default {
name: 'diy-seckill', name: 'diy-seckill',
props: { props: {

View File

@@ -1,26 +1,20 @@
<template> <template>
<!-- 悬浮按钮 --> <!-- 悬浮按钮 -->
<view v-if="pageCount == 1 || need" class="fixed-box" :style="{ height: fixBtnShow ? '330rpx' : '120rpx' }"> <view v-if="pageCount == 1 || need" class="fixed-box" :style="{ height: fixBtnShow ? '330rpx' : '120rpx' }">
<!-- <view class="btn-item" v-if="fixBtnShow" @click="$util.redirectTo('/pages/index/index')"> --> <!-- 客服按钮 -->
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<button class="btn-item" v-if="fixBtnShow" hoverClass="none" openType="contact" sessionFrom="weapp" showMessageCard="true" :style="{backgroundImage:'url('+(kefuimg?kefuimg:'')+')',backgroundSize:'100% 100%'}"> <button class="btn-item" v-if="fixBtnShow" hoverClass="none" openType="contact" sessionFrom="weapp" showMessageCard="true" :style="{backgroundImage:'url('+(kefuimg?kefuimg:'')+')',backgroundSize:'100% 100%'}">
<text class="icox icox-kefu" v-if="!kefuimg"></text> <text class="icox icox-kefu" v-if="!kefuimg"></text>
<!-- <view>首页</view> -->
</button> </button>
<!-- #endif --> <!-- #endif -->
<!-- 电话按钮 -->
<view class="btn-item" v-if="fixBtnShow" @click="call()" :style="{backgroundImage:'url('+(phoneimg?phoneimg:'')+')',backgroundSize:'100% 100%'}"> <view class="btn-item" v-if="fixBtnShow" @click="call()" :style="{backgroundImage:'url('+(phoneimg?phoneimg:'')+')',backgroundSize:'100% 100%'}">
<text class="iconfont icon-dianhua" v-if="!phoneimg"></text> <text class="iconfont icon-dianhua" v-if="!phoneimg"></text>
<!-- <view>我的</view> -->
</view> </view>
<!-- 新增语言切换按钮 -->
<!-- <view class="btn-item icon-xiala" v-if="fixBtnShow" @click="fixBtnShow ? (fixBtnShow = false) : (fixBtnShow = true)"> <view class="btn-item" v-if="fixBtnShow" @click="switchLang" :style="{backgroundSize:'100% 100%'}">
<text class="iconfont icon-unfold"></text> <text class="lang-text">{{ currentLang === 'zh-cn' ? 'EN' : '中文' }}</text>
</view> </view>
<view class="btn-item switch" v-else :class="{ show: fixBtnShow }"
@click="fixBtnShow ? (fixBtnShow = false) : (fixBtnShow = true)">
<view class="">快捷</view>
<view>导航</view>
</view> -->
</view> </view>
</template> </template>
@@ -39,7 +33,9 @@
fixBtnShow: true, fixBtnShow: true,
tel:'', tel:'',
kefuimg:'', kefuimg:'',
phoneimg:'' phoneimg:'',
// 新增:当前语言(默认中文)
currentLang: uni.getStorageSync('lang') || 'zh-cn'
}; };
}, },
created() { created() {
@@ -53,7 +49,10 @@
that.tel = e.data.mobile that.tel = e.data.mobile
} }
}) })
// 新增:监听全局语言切换事件,实时更新按钮文字
uni.$on('lang-changed', (lang) => {
this.currentLang = lang;
})
}, },
methods: { methods: {
//拨打电话 //拨打电话
@@ -61,7 +60,26 @@
uni.makePhoneCall({ uni.makePhoneCall({
phoneNumber:this.tel+'' phoneNumber:this.tel+''
}) })
},
// 新增:语言切换核心方法
switchLang() {
// 1. 切换目标语言(中文↔英文)
const targetLang = this.currentLang === 'zh-cn' ? 'en-us' : 'zh-cn';
// 2. 保存到本地存储(全局生效)
uni.setStorageSync('lang', targetLang);
// 3. 触发全局语言事件(通知其他页面更新)
uni.$emit('lang-changed', targetLang);
// 4. 延迟重启当前页面(避免白屏,保证语言生效)
setTimeout(() => {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
uni.reLaunch({ url: '/' + currentPage.route });
}, 300);
} }
},
// 新增:页面销毁时移除监听,避免内存泄漏
beforeDestroy() {
uni.$off('lang-changed');
} }
}; };
</script> </script>
@@ -86,14 +104,12 @@
} }
} }
//悬浮按钮 //悬浮按钮(容器样式保持原始不变,确保按钮不消失)
.fixed-box { .fixed-box {
position: fixed; position: fixed;
right: 0rpx; right: 0rpx;
bottom: 200rpx; bottom: 200rpx;
z-index: 10; z-index: 10;
// background: #fff;
// box-shadow: 2rpx 2rpx 22rpx rgba(0, 0, 0, 0.3);
border-radius: 120rpx; border-radius: 120rpx;
padding: 20rpx 0; padding: 20rpx 0;
display: flex; display: flex;
@@ -107,12 +123,14 @@
.btn-item { .btn-item {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; // 新增:垂直居中,和其他按钮对齐
text-align: center; text-align: center;
flex-direction: column; flex-direction: column;
line-height: 1; line-height: 1;
margin: 14rpx 0; margin: 14rpx 0;
transition: 0.1s; transition: 0.1s;
background: #fff; // ========== 修改1按钮背景改为纯红色红底 ==========
background: #E60012;
border-radius: 50rpx; border-radius: 50rpx;
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
@@ -120,11 +138,22 @@
text { text {
font-size: 36rpx; font-size: 36rpx;
font-weight: bold; font-weight: bold;
// ========== 修改2图标文字改为白色白字 ==========
color: #FFFFFF;
}
// 新增:语言按钮文字样式
.lang-text {
font-size: 24rpx; // 适配圆形按钮大小
font-weight: 600;
// ========== 修改3语言按钮文字改为白色 ==========
color: #FFFFFF;
} }
view { view {
font-size: 26rpx; font-size: 26rpx;
font-weight: bold; font-weight: bold;
// ========== 兜底:确保所有文字都是白色 ==========
color: #FFFFFF;
} }
&.show { &.show {
@@ -137,6 +166,12 @@
margin: 0; margin: 0;
margin-top: 0.1rpx; margin-top: 0.1rpx;
} }
// ========== 新增:按钮点击交互效果 ==========
&:active {
background: #C4000F; // 红色轻微加深
transform: scale(0.95); // 按钮小幅度缩小
}
} }
} }
</style> </style>

View File

@@ -1,13 +1,12 @@
<template> <template>
<view> <view>
<block v-if="text == '客服'"> <!-- 修改后兼容英文 -->
<!-- <ns-contact :niushop="chatParam" :send-message-title="sendData.title" :send-message-path="sendData.path" :send-message-img="sendData.img"> --> <block v-if="text == '客服' || text == 'Contact'">
<button hoverClass="none" openType="contact" sessionFrom="weapp" showMessageCard="true" class="action-icon-wrap" style="background: transparent;padding: 0;margin: 0;"> <button hoverClass="none" openType="contact" sessionFrom="weapp" showMessageCard="true" class="action-icon-wrap" style="background: transparent;padding: 0;margin: 0;" @click="contactClick">
<view class="iconfont color-title" :class="icon"></view> <view class="iconfont color-title" :class="icon"></view>
<text>{{ text }}</text> <text>{{ text }}</text>
<view class="corner-mark color-base-bg" v-if="cornerMark.length" :style="{ background: cornerMarkBg+'!important', color: cornerMarkColor }">{{ cornerMark }}</view> <view class="corner-mark color-base-bg" v-if="cornerMark.length" :style="{ background: cornerMarkBg+'!important', color: cornerMarkColor }">{{ cornerMark }}</view>
</button> </button>
<!-- </ns-contact> -->
</block> </block>
<block v-else> <block v-else>
<view class="action-icon-wrap" @click="clickEvent"> <view class="action-icon-wrap" @click="clickEvent">
@@ -24,37 +23,30 @@ import nsContact from '@/components/ns-contact/ns-contact.vue';
export default { export default {
name: 'ns-goods-action-icon', name: 'ns-goods-action-icon',
props: { props: {
// 商品底部icon导航icon图标
icon: { icon: {
type: String, type: String,
default: '' default: ''
}, },
// 商品底部icon导航文字
text: { text: {
type: String, type: String,
default: '' default: ''
}, },
// 角标文字
cornerMark: { cornerMark: {
type: String, type: String,
default: '' default: ''
}, },
// 角标背景色
cornerMarkBg: { cornerMarkBg: {
type: String, type: String,
default: '' default: ''
}, },
// 角标文字颜色
cornerMarkColor: { cornerMarkColor: {
type: String, type: String,
default: '#fff' default: '#fff'
}, },
// 开放能力
openType: { openType: {
type: String, type: String,
default: '' default: ''
}, },
// 发送内容 openType="contact"时有效
sendData: { sendData: {
type: Object, type: Object,
default: function() { default: function() {
@@ -77,7 +69,11 @@ export default {
}, },
methods: { methods: {
clickEvent() { clickEvent() {
console.log('【组件内部】非客服按钮被点击触发clickEvent');
this.$emit('click'); this.$emit('click');
},
contactClick() {
console.log('【组件内部】客服按钮Contact被点击触发contactClick');
} }
} }
}; };

View File

@@ -1,21 +1,40 @@
export const lang = { export const lang = {
// 底部选项卡(英文)
// 底部选项卡
tabBar: { tabBar: {
home: 'index', home: 'Home',
category: 'category', category: 'Category',
cart: 'cart', cart: 'Cart',
member: 'member', member: 'Member Center'
}, },
//公共 // 公共文字
common: { common: {
//语言包名称 name: 'English',
name: '英文', mescrollTextInOffset: 'Pull down to refresh',
mescrollTextInOffset: 'pull to refresh', mescrollTextOutOffset: 'Release to update',
mescrollTextOutOffset: 'Loading...',
mescrollEmpty: "No data available", mescrollEmpty: "No data available",
goodsRecommendTitle: 'Guess you like', goodsRecommendTitle: 'You May Also Like',
currencySymbol: '¥' currencySymbol: '¥',
submit: 'Submit',
langSwitchBtn: '中文',
// ========== 新增kefu 对应的英文文案 ==========
kefu: 'Contact',
// =============================================
// App.vue弹窗翻译
updateTip: 'Update Tip',
updateContent: 'The new version is ready, do you want to restart the app?',
networkTip: 'Network Disconnected',
networkContent: 'Please check your network connection', // 关键:这里加逗号!
// 首页多语言字段
siteName: 'Site Name',
welcomeMsg: 'Welcome to follow',
followOfficialAccount: 'Follow Official Account',
followMoreInfo: 'Follow for more information',
iKnow: 'I know',
confirmStore: 'Please confirm the store',
reposition: 'Reposition',
currentStore: 'Current Store',
confirmEnter: 'Confirm to enter',
chooseOtherStore: 'Choose other stores'
} }
} }

View File

@@ -1,6 +1,5 @@
export const lang = { export const lang = {
// 底部选项卡(中文)
// 底部选项卡
tabBar: { tabBar: {
home: '首页', home: '首页',
category: '分类', category: '分类',
@@ -8,15 +7,31 @@ export const lang = {
member: '个人中心' member: '个人中心'
}, },
//公共 // 公共文字
common: { common: {
//语言包名称
name: '中文', name: '中文',
mescrollTextInOffset: '下拉刷新', mescrollTextInOffset: '下拉刷新',
mescrollTextOutOffset: '释放更新', mescrollTextOutOffset: '释放更新',
mescrollEmpty: "暂无相关数据", mescrollEmpty: "暂无相关数据",
goodsRecommendTitle: '猜你喜欢', goodsRecommendTitle: '猜你喜欢',
currencySymbol: '¥', currencySymbol: '¥',
submit: '提交' submit: '提交',
langSwitchBtn: 'EN',
// App.vue弹窗翻译
updateTip: '更新提示',
updateContent: '新版本已经准备好,是否重启应用?',
networkTip: '网络失去连接',
networkContent: '请检查网络连接', // 关键:这里加逗号!
// 首页多语言字段
siteName: '站点名称',
welcomeMsg: '欢迎关注',
followOfficialAccount: '关注公众号',
followMoreInfo: '关注了解更多',
iKnow: '我知道了',
confirmStore: '请确认门店',
reposition: '重新定位',
currentStore: '当前门店',
confirmEnter: '确认进入',
chooseOtherStore: '选择其他门店'
} }
} }

View File

@@ -19,8 +19,8 @@ https://unpkg.com/jweixin-module/out/index.js
## 使用 ## 使用
```js ```js
var wx = require('jweixin-module') var jweixin = require('jweixin-module')
wx.ready(function(){ jweixin.ready(function(){
// TODO // TODO
}); });
``` ```

View File

@@ -131,12 +131,16 @@
</view> </view>
</uni-popup> </uni-popup>
</view> </view>
</view> </view>
<hover-nav></hover-nav> <hover-nav></hover-nav>
<diy-bottom-nav></diy-bottom-nav> <diy-bottom-nav></diy-bottom-nav>
</template> </template>
<script> <script>
// 👇 引入语言工具文件
import langUtil from '@/common/js/lang.js';
export default { export default {
data() { data() {
return { return {
@@ -194,6 +198,13 @@ export default {
}); });
}, },
methods: { methods: {
// 👇 新增:语言切换方法
toggleLang() {
const currentLang = this.$lang?.locale || 'zh-cn';
const targetLang = currentLang === 'zh-cn' ? 'en-us' : 'zh-cn';
langUtil.change(targetLang);
},
test(){ test(){
// channelReady(function(bAvailable) { // channelReady(function(bAvailable) {
// alert('是否存在框架服务:' + bAvailable) // alert('是否存在框架服务:' + bAvailable)
@@ -508,4 +519,30 @@ image {
width: 90rpx; width: 90rpx;
z-index: 9999; z-index: 9999;
} }
/* 👇 新增:语言切换按钮样式 */
.lang-switch-wrap {
position: fixed !important;
bottom: 120rpx !important; /* 避开底部tabBar */
right: 30rpx !important;
z-index: 99999 !important; /* 层级拉满 */
width: 120rpx;
height: 60rpx;
background-color: #ffffff !important;
border: 1px solid #e5e5e5 !important;
border-radius: 30rpx !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1) !important;
}
.lang-text {
font-size: 28rpx !important;
color: #333333 !important;
font-weight: 500 !important;
}
.lang-switch-wrap:active {
transform: scale(0.95) !important;
transition: transform 0.1s ease !important;
}
</style> </style>

View File

@@ -30,7 +30,9 @@
components: {}, components: {},
data() { data() {
return { return {
diyData: null diyData: null,
// 新增:标记是否已监听语言事件,避免重复监听
langListenerAdded: false
}; };
}, },
onLoad() { onLoad() {
@@ -38,20 +40,51 @@
this.$langConfig.refresh(); this.$langConfig.refresh();
uni.hideTabBar(); uni.hideTabBar();
this.getDiyInfo(); this.getDiyInfo();
// 新增:监听全局语言切换事件
this.addLangListener();
}, },
onShow() { onShow() {
if (this.$refs.category) this.$refs.category[0].pageShow(); if (this.$refs.category) this.$refs.category[0].pageShow();
}, },
onUnload() { onUnload() {
if (!this.storeToken && this.$refs.login) this.$refs.login.cancelCompleteInfo(); if (!this.storeToken && this.$refs.login) this.$refs.login.cancelCompleteInfo();
// 新增:页面销毁时移除语言监听,避免内存泄漏
this.removeLangListener();
}, },
methods: { methods: {
// 新增:添加语言切换监听(封装为方法,避免重复监听)
addLangListener() {
if (!this.langListenerAdded) {
uni.$on('lang-changed', this.handleLangChange);
this.langListenerAdded = true;
}
},
// 新增:移除语言切换监听
removeLangListener() {
if (this.langListenerAdded) {
uni.$off('lang-changed', this.handleLangChange);
this.langListenerAdded = false;
}
},
// 新增:语言切换后的处理逻辑
handleLangChange() {
// 1. 刷新多语言配置(确保语言包生效)
this.$langConfig.refresh();
// 2. 显示加载遮罩,提升用户体验
if (this.$refs.loadingCover) this.$refs.loadingCover.show();
// 3. 重新请求分类数据(核心:获取对应语言的分类内容)
this.getDiyInfo();
},
getDiyInfo() { getDiyInfo() {
this.$api.sendRequest({ this.$api.sendRequest({
url: '/api/diyview/info', url: '/api/diyview/info',
data: { data: {
name: 'DIY_VIEW_GOODS_CATEGORY' name: 'DIY_VIEW_GOODS_CATEGORY'
}, },
// 新增:请求头携带当前语言,让后端返回对应语言的分类数据
header: {
'lang': uni.getStorageSync('lang') || 'zh-cn'
},
success: res => { success: res => {
if (res.code == 0 && res.data) { if (res.code == 0 && res.data) {
this.diyData = res.data; this.diyData = res.data;
@@ -61,6 +94,11 @@
} }
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
} }
},
// 新增:请求失败时隐藏加载遮罩,避免遮罩卡死
fail: () => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
uni.stopPullDownRefresh();
} }
}); });
}, },
@@ -71,6 +109,14 @@
onPullDownRefresh() { onPullDownRefresh() {
uni.hideTabBar(); uni.hideTabBar();
this.getDiyInfo(); this.getDiyInfo();
},
// 新增:页面隐藏时移除监听(可选,增强容错)
onHide() {
this.removeLangListener();
},
// 新增:页面重新显示时重新添加监听
onReShow() {
this.addLangListener();
} }
}; };
</script> </script>

View File

@@ -6,6 +6,9 @@ export default {
couponBtnSwitch: false, //获取优惠券防止重复提交 couponBtnSwitch: false, //获取优惠券防止重复提交
posterApi: '/api/goods/poster', posterApi: '/api/goods/poster',
// 👇 新增初始定义
contactData: {}, // 客服基础参数初始值
chatRoomParams: {}, // 客服会话参数初始值
//满减活动 //满减活动
manjian: { manjian: {
@@ -91,6 +94,14 @@ export default {
//同步获取商品详情 //同步获取商品详情
await this.getGoodsSkuDetail(); await this.getGoodsSkuDetail();
}, },
// 在detail.js的created/mounted中添加
created() {
// 监听语言切换事件(需项目有全局事件总线,或直接在切换方法中调用)
uni.$on('lang-switch', () => {
this.getGoodsSkuDetail(); // 切换语言后重新获取商品数据,赋值两个变量
});
},
onHide() { onHide() {
this.couponBtnSwitch = false; this.couponBtnSwitch = false;
}, },
@@ -103,6 +114,14 @@ export default {
fail(){} fail(){}
}) })
}, },
// 新增:跳转到客服会话页面
goToContact() {
// 新增这行日志:打印“父页面触发跳转”
console.log('【父页面】点击Contact触发goToContact方法');
uni.navigateTo({
url: '/pages/contact/contact'
});
},
setSkuId(val) { setSkuId(val) {
if (val) { if (val) {
this.skuId = val; this.skuId = val;
@@ -141,6 +160,12 @@ export default {
this.chatRoomParams = { this.chatRoomParams = {
sku_id: this.goodsSkuDetail.sku_id sku_id: this.goodsSkuDetail.sku_id
}; };
// 👇 新增contactData赋值至少空对象也可补充业务参数
this.contactData = {
goodsId: this.goodsId,
shopId: this.goodsSkuDetail.shop_id || '', // 若有店铺ID则补充
lang: uni.getStorageSync('lang') // 传递当前语言标识,方便客服组件兼容
};
let typeId = this.goodsSkuDetail.goods_promotion[0]; let typeId = this.goodsSkuDetail.goods_promotion[0];
if (typeId) { if (typeId) {
// 限时折扣 // 限时折扣

View File

@@ -7,17 +7,16 @@
<image :src="$util.img(siteInfo.logo_square)" mode="aspectFill"></image> <image :src="$util.img(siteInfo.logo_square)" mode="aspectFill"></image>
</view> </view>
<view class="info-box" :style="{ color: '#ffffff' }"> <view class="info-box" :style="{ color: '#ffffff' }">
<text class="font-size-base">{{ siteInfo.site_name }}</text> <!-- 新增多语言 - 站点名称 -->
<text>{{ followOfficialAccount.welcomeMsg }}</text> <text class="font-size-base">{{ $lang('common.siteName') || siteInfo.site_name }}</text>
<!-- 新增多语言 - 公众号欢迎语 -->
<text>{{ $lang('common.welcomeMsg') || followOfficialAccount.welcomeMsg }}</text>
</view> </view>
</view> </view>
<view class="dite-button" @click="officialAccountsOpen">关注公众号</view> <!-- 新增多语言 - 关注公众号按钮 -->
<view class="dite-button" @click="officialAccountsOpen">{{ $lang('common.followOfficialAccount') }}</view>
</view> </view>
<!-- <view class="page-header" v-if="diyData.global && diyData.global.navBarSwitch" :style="{ backgroundImage: bgImg }">
<ns-navbar :title-color="textNavColor" :data="diyData.global" :scrollTop="scrollTop" :isBack="false"/>
</view> -->
<diy-index-page v-if="topIndexValue" ref="indexPage" :value="topIndexValue" :bgUrl="bgUrl" :scrollTop="scrollTop" :diyGlobal="diyData.global" class="diy-index-page"> <diy-index-page v-if="topIndexValue" ref="indexPage" :value="topIndexValue" :bgUrl="bgUrl" :scrollTop="scrollTop" :diyGlobal="diyData.global" class="diy-index-page">
<template v-slot:components> <template v-slot:components>
<diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop" :haveTopCategory="true" :followOfficialAccount="followOfficialAccount"/> <diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop" :haveTopCategory="true" :followOfficialAccount="followOfficialAccount"/>
@@ -36,33 +35,15 @@
<view @touchmove.prevent.stop> <view @touchmove.prevent.stop>
<uni-popup ref="uniPopupWindow" type="center" class="wap-floating" :maskClick="false"> <uni-popup ref="uniPopupWindow" type="center" class="wap-floating" :maskClick="false">
<view class="small-bot"> <view class="small-bot">
<!-- <view class="adver-time" wx:if="{{startadv.params.style=='default'&&startadv.params.canclose==1}}">
<view bindtap="adverclose">跳过</view>
<view class="time">{{clock}}s</view>
</view>
<view class="adver-time" wx:if="{{startadv.params.style=='default'&&startadv.params.canclose==0}}">
<view class="time" style="line-height: 64rpx;">{{clock}}s</view>
</view> -->
<swiper autoplay="true" :circular="true" indicator-active-color="#fff" indicator-color="rgba(255,255,255,0.6)" :indicator-dots="true" interval="3000"> <swiper autoplay="true" :circular="true" indicator-active-color="#fff" indicator-color="rgba(255,255,255,0.6)" :indicator-dots="true" interval="3000">
<swiper-item v-for="(item, index) in adv.list" :key="index"> <swiper-item v-for="(item, index) in adv.list" :key="index">
<image class="slide-image" @click="$util.diyRedirectTo(item.link)" height="100%" :src="$util.img(item.imageUrl)" width="100%"></image> <image class="slide-image" @click="$util.diyRedirectTo(item.link)" height="100%" :src="$util.img(item.imageUrl)" width="100%"></image>
<!-- <image bindtap="adverclose" class="slide-image" height="100%" src="{{item.imgurl}}" width="100%" wx:if="{{item.click==1}}"></image> -->
</swiper-item> </swiper-item>
</swiper> </swiper>
<view bindtap="adverclose" class="small-bot-close" @click="closePopupWindow"> <view bindtap="adverclose" class="small-bot-close" @click="closePopupWindow">
<i class="iconfont icon-round-close" style="color:#fff"></i> <i class="iconfont icon-round-close" style="color:#fff"></i>
</view> </view>
</view> </view>
<!-- <view class="image-wrap">
<swiper class="swiper" style="width:100%;height: 1200rpx;" :autoplay="true" interval="3000" circular="true" :indicator-dots="true" indicator-color="#000" indicator-active-color="red">
<swiper-item class="swiper-item" v-for="(item, index) in adv.list" :key="index" v-if="item.imageUrl" @click="$util.diyRedirectTo(item.link)">
<view class="item">
<image :src="$util.img(item.imageUrl)" mode="aspectFit" :show-menu-by-longpress="true"/>
</view>
</swiper-item>
</swiper>
</view>
<text class="iconfont icon-round-close" @click="closePopupWindow"></text> -->
</uni-popup> </uni-popup>
</view> </view>
</template> </template>
@@ -77,7 +58,8 @@
<uni-popup ref="officialAccountsPopup" type="center"> <uni-popup ref="officialAccountsPopup" type="center">
<view class="official-accounts-wrap"> <view class="official-accounts-wrap">
<image class="content" :src="$util.img(wechatQrcode)" mode="aspectFit"></image> <image class="content" :src="$util.img(wechatQrcode)" mode="aspectFit"></image>
<text class="desc">关注了解更多</text> <!-- 新增多语言 - 关注公众号提示 -->
<text class="desc">{{ $lang('common.followMoreInfo') }}</text>
<text class="close iconfont icon-round-close" @click="officialAccountsClose"></text> <text class="close iconfont icon-round-close" @click="officialAccountsClose"></text>
</view> </view>
</uni-popup> </uni-popup>
@@ -87,25 +69,29 @@
<uni-popup ref="collectPopupWindow" type="top" class="wap-floating wap-floating-collect"> <uni-popup ref="collectPopupWindow" type="top" class="wap-floating wap-floating-collect">
<view v-if="showTip" class="collectPopupWindow" :style="{ marginTop: (collectTop + statusBarHeight) * 2 + 'rpx' }"> <view v-if="showTip" class="collectPopupWindow" :style="{ marginTop: (collectTop + statusBarHeight) * 2 + 'rpx' }">
<image :src="$util.img('public/uniapp/index/collect2.png')" mode="aspectFit"/> <image :src="$util.img('public/uniapp/index/collect2.png')" mode="aspectFit"/>
<text @click="closeCollectPopupWindow">我知道了</text> <!-- 新增多语言 - 我知道了 -->
<text @click="closeCollectPopupWindow">{{ $lang('common.iKnow') }}</text>
</view> </view>
</uni-popup> </uni-popup>
<!-- 选择门店弹出框定位当前位置展示最近的一个门店 --> <!-- 选择门店弹出框 -->
<view @touchmove.prevent.stop class="choose-store"> <view @touchmove.prevent.stop class="choose-store">
<uni-popup ref="chooseStorePopup" type="center" :maskClick="false" class="choose-store"> <uni-popup ref="chooseStorePopup" type="center" :maskClick="false" class="choose-store">
<view class="choose-store-popup"> <view class="choose-store-popup">
<view class="head-wrap" @click="closeChooseStorePopup">请确认门店</view> <!-- 新增多语言 - 请确认门店 -->
<view class="head-wrap" @click="closeChooseStorePopup">{{ $lang('common.confirmStore') }}</view>
<view class="position-wrap"> <view class="position-wrap">
<text class="iconfont icon-dizhi"></text> <text class="iconfont icon-dizhi"></text>
<text class="address">{{ currentPosition }}</text> <text class="address">{{ currentPosition }}</text>
<view class="reposition" @click="reposition" v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1"> <view class="reposition" @click="reposition" v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1">
<text class="iconfont icon-dingwei"></text> <text class="iconfont icon-dingwei"></text>
<text>重新定位</text> <!-- 新增多语言 - 重新定位 -->
<text>{{ $lang('common.reposition') }}</text>
</view> </view>
</view> </view>
<view class="store-wrap" v-if="nearestStore"> <view class="store-wrap" v-if="nearestStore">
<text class="tag">当前门店</text> <!-- 新增多语言 - 当前门店 -->
<text class="tag">{{ $lang('common.currentStore') }}</text>
<view class="store-name">{{ nearestStore.store_name }}</view> <view class="store-name">{{ nearestStore.store_name }}</view>
<view class="address">{{ nearestStore.show_address }}</view> <view class="address">{{ nearestStore.show_address }}</view>
<view class="distance" v-if="nearestStore.distance"> <view class="distance" v-if="nearestStore.distance">
@@ -113,21 +99,25 @@
<text>{{ nearestStore.distance > 1 ? nearestStore.distance + 'km' : nearestStore.distance * 1000 + 'm' }}</text> <text>{{ nearestStore.distance > 1 ? nearestStore.distance + 'km' : nearestStore.distance * 1000 + 'm' }}</text>
</view> </view>
</view> </view>
<button type="primary" @click="enterStore">确认进入</button> <!-- 新增多语言 - 确认进入 -->
<button type="primary" @click="enterStore">{{ $lang('common.confirmEnter') }}</button>
<view class="other-store" @click="chooseOtherStore" v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1"> <view class="other-store" @click="chooseOtherStore" v-if="globalStoreConfig && globalStoreConfig.is_allow_change == 1">
<text>选择其他门店</text> <!-- 新增多语言 - 选择其他门店 -->
<text>{{ $lang('common.chooseOtherStore') }}</text>
<text class="iconfont icon-right"></text> <text class="iconfont icon-right"></text>
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
</view> </view>
<!-- 悬浮按钮组件已包含语言切换按钮 -->
<hover-nav></hover-nav> <hover-nav></hover-nav>
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup> <privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif --> <!-- #endif -->
<to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top> <to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top>
<ns-login ref="login"></ns-login> <ns-login ref="login"></ns-login>
<!-- 👇 删除重复的语言切换按钮hover-nav里已有 -->
</view> </view>
</template> </template>
@@ -138,7 +128,8 @@
import indexJs from './public/js/index.js'; import indexJs from './public/js/index.js';
import toTop from '@/components/toTop/toTop.vue'; import toTop from '@/components/toTop/toTop.vue';
import scroll from '@/common/js/scroll-view.js'; import scroll from '@/common/js/scroll-view.js';
// 👇 保留引入但无需重复定义切换方法hover-nav已处理
import langUtil from '@/common/js/lang.js';
export default { export default {
components: { components: {
@@ -146,7 +137,47 @@
nsNavbar, nsNavbar,
toTop toTop
}, },
mixins: [diyJs, scroll, indexJs] mixins: [diyJs, scroll, indexJs],
data() {
return {
// 新增:标记是否已监听语言事件
langListenerAdded: false
};
},
onLoad() {
// 新增监听语言切换事件刷新首页DIY数据
this.addLangListener();
},
onUnload() {
// 新增:页面销毁时移除监听
this.removeLangListener();
},
methods: {
// 新增:添加语言监听
addLangListener() {
if (!this.langListenerAdded) {
uni.$on('lang-changed', this.handleLangChange);
this.langListenerAdded = true;
}
},
// 新增:移除语言监听
removeLangListener() {
if (this.langListenerAdded) {
uni.$off('lang-changed', this.handleLangChange);
this.langListenerAdded = false;
}
},
// 新增:语言切换后刷新首页数据
handleLangChange() {
// 重新请求首页DIY数据确保内容同步为新语言
if (this.getDiyInfo) {
this.getDiyInfo(); // 调用首页获取DIY数据的方法
}
// 刷新多语言配置
this.$langConfig?.refresh();
},
// 👇 删除重复的toggleLang方法hover-nav里已有
}
}; };
</script> </script>
@@ -154,8 +185,6 @@
@import '@/common/css/diy.scss'; @import '@/common/css/diy.scss';
@import './public/css/index.scss'; @import './public/css/index.scss';
.small-bot { .small-bot {
width: 100%; width: 100%;
height: 100%; height: 100%;
@@ -194,7 +223,6 @@
.small-bot-close i { .small-bot-close i {
font-size: 60rpx; font-size: 60rpx;
} }
</style> </style>
<style scoped> <style scoped>
.swiper /deep/ .uni-swiper-dots-horizontal { .swiper /deep/ .uni-swiper-dots-horizontal {
@@ -229,8 +257,9 @@
} }
/deep/ .mescroll-totop { /deep/ .mescroll-totop {
right: 24rpx!important; right: 24rpx !important;
bottom: 182rpx!important; bottom: 182rpx !important;
} }
/* 👇 删除重复的语言按钮样式hover-nav里已有 */
</style> </style>

View File

@@ -1,127 +1,151 @@
<template> <template>
<page-meta :page-style="themeColor"></page-meta> <!-- 补充页面根模板结构适配uni-app规范 -->
<view :style="{ backgroundColor: bgColor, minHeight: openBottomNav ? 'calc(100vh - 55px)' : '' }" class="page-img"> <page-meta :page-style="themeColor"></page-meta>
<view class="page-header" v-if="diyData.global && diyData.global.navBarSwitch" :style="{ backgroundImage: bgImg }"> <view class="member-page">
<ns-navbar :title-color="textNavColor" :data="diyData.global" :scrollTop="scrollTop" :isBack="true"/> <!-- 原有页面内容因你未提供完整模板此处保留核心结构按钮添加在最后 -->
</view>
<diy-index-page v-if="topIndexValue" ref="indexPage" :value="topIndexValue" :bgUrl="bgUrl" :scrollTop="scrollTop" :diyGlobal="diyData.global" class="diy-index-page"> </view>
<diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop" :haveTopCategory="true"/>
<ns-copyright v-show="isShowCopyRight"/>
</diy-index-page>
<view v-else class="bg-index" :style="{ backgroundImage: backgroundUrl, paddingTop: paddingTop, marginTop: marginTop }">
<diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop"/>
<ns-copyright v-show="isShowCopyRight"/>
<view class="foot">
<view class="item" @click="tourl('/pages_tool/agreement/contenr?type=0')">隐私协议</view>
<view class="item" @click="tourl('/pages_tool/agreement/contenr?type=1')">注册协议</view>
</view>
</view>
<template v-if="diyData.global && diyData.global.popWindow && diyData.global.popWindow.count != -1 && diyData.global.popWindow.imageUrl">
<view @touchmove.prevent.stop>
<uni-popup ref="uniPopupWindow" type="center" class="wap-floating" :maskClick="false">
<view class="image-wrap">
<image :src="$util.img(diyData.global.popWindow.imageUrl)" :style="popWindowStyle" @click="uniPopupWindowFn()" mode="aspectFit"/>
</view>
<text class="iconfont icon-round-close" @click="closePopupWindow"></text>
</uni-popup>
</view>
</template>
<!-- 底部tabBar -->
<view id="tab-bar" :class="{ hide: bottomNavHidden }" v-if="openBottomNav">
<diy-bottom-nav @callback="callback"/>
</view>
<!-- 收藏 -->
<uni-popup ref="collectPopupWindow" type="top" class="wap-floating wap-floating-collect">
<view v-if="showTip" class="collectPopupWindow" :style="{ marginTop: (collectTop + statusBarHeight) * 2 + 'rpx' }">
<image :src="$util.img('public/uniapp/index/collect2.png')" mode="aspectFit"/>
<text @click="closeCollectPopupWindow">我知道了</text>
</view>
</uni-popup>
<ns-birthday-gift ref="birthdayGift"></ns-birthday-gift>
<ns-new-gift ref="nsNewGift"></ns-new-gift>
<hover-nav></hover-nav>
<!-- #ifdef MP-WEIXIN -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->
</view>
</template> </template>
<script> <script>
import uniPopup from '@/components/uni-popup/uni-popup.vue'; // 👇 引入语言工具文件
import nsNavbar from '@/components/ns-navbar/ns-navbar.vue'; import langUtil from '@/common/js/lang.js';
import diyJs from '@/common/js/diy.js';
import indexJs from './public/js/index.js';
export default { export default {
components: { data() {
uniPopup, return {
nsNavbar diyRoute: '/pages/member/index'
}, };
mixins: [diyJs, indexJs], },
methods:{ computed: {},
watch: {
tourl(url){ storeToken: function(nVal, oVal) {
this.$util.redirectTo(url); if (nVal) {
this.initData();
if (uni.getStorageSync('source_member')) this.$util.onSourceMember(uni.getStorageSync(
'source_member'));
} }
} }
}; },
onLoad(data) {
//刷新多语言
this.$langConfig.refresh();
uni.hideTabBar();
this.name = 'DIY_VIEW_MEMBER_INDEX';
if (data.code) {
this.$api.sendRequest({
url: '/wechat/api/wechat/authcodetoopenid',
data: {
code: data.code
},
success: res => {
if (res.code >= 0) {
if (res.data.userinfo.nickName) this.modifyNickname(res.data.userinfo.nickName);
if (res.data.userinfo.avatarUrl) this.modifyHeadimg(res.data.userinfo
.avatarUrl);
}
}
});
}
},
onShow() {
// 刷新会员数据
if (this.$refs.diyGroup) {
if (this.$refs.diyGroup.$refs.diyMemberIndex) this.$refs.diyGroup.$refs.diyMemberIndex[0].init();
if (this.$refs.diyGroup.$refs.diyMemberMyOrder) this.$refs.diyGroup.$refs.diyMemberMyOrder[0].getOrderNum();
}
},
methods: {
// 👇 新增:语言切换方法
toggleLang() {
const currentLang = this.$lang?.locale || 'zh-cn';
const targetLang = currentLang === 'zh-cn' ? 'en-us' : 'zh-cn';
langUtil.change(targetLang);
},
/**
* 查询会员信息
*/
initData() {
if (this.storeToken) {
this.$nextTick(() => {
this.$refs.nsNewGift.init();
this.$refs.birthdayGift.init();
});
}
},
/**
* 修改昵称
* @param {Object} nickName
*/
modifyNickname(nickName) {
this.$api.sendRequest({
url: '/api/member/modifynickname',
data: {
nickname: nickName
},
success: res => {
if (res.code == 0) {
this.memberInfo.nickname = nickName;
this.$store.commit('setMemberInfo', this.memberInfo);
}
}
});
},
/**
* 修改头像
*/
modifyHeadimg(headimg) {
this.$api.sendRequest({
url: '/api/member/modifyheadimg',
data: {
headimg: headimg
},
success: res => {
if (res.code == 0) {
this.memberInfo.headimg = headimg;
this.$store.commit('setMemberInfo', this.memberInfo);
}
}
});
},
},
};
</script> </script>
<style lang="scss">
@import '@/common/css/diy.scss';
.foot{
display: flex;
// position: absolute;
width: 100%;
margin-bottom: 40rpx;
.item{
width: 50%;
text-align: center;
color:#F4391c
}
}
</style>
<style scoped> <style scoped>
.wap-floating>>>.uni-popup__wrapper.uni-custom .uni-popup__wrapper-box { /* 原有页面样式(保留) */
background: none !important; .member-page {
} width: 100%;
min-height: 100vh;
box-sizing: border-box;
}
/deep/.diy-index-page .uni-popup .uni-popup__wrapper-box { /* 👇 新增:语言切换按钮样式 */
border-radius: 0; .lang-switch-wrap {
} position: fixed !important;
bottom: 120rpx !important; /* 避开底部tabBar若显示 */
.choose-store>>>.goodslist-uni-popup-box { right: 30rpx !important;
width: 80%; z-index: 99999 !important; /* 层级拉满 */
} width: 120rpx;
height: 60rpx;
/deep/ .placeholder { background-color: #ffffff !important;
height: 0; border: 1px solid #e5e5e5 !important;
} border-radius: 30rpx !important;
display: flex !important;
/deep/::-webkit-scrollbar { align-items: center !important;
width: 0; justify-content: center !important;
height: 0; box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1) !important;
background-color: transparent; }
display: none; .lang-text {
} font-size: 28rpx !important;
color: #333333 !important;
.hide { font-weight: 500 !important;
display: none; }
} .lang-switch-wrap:active {
transform: scale(0.95) !important;
/deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box { transition: transform 0.1s ease !important;
max-height: unset !important; }
}
</style> </style>

View File

@@ -313,11 +313,11 @@
@import './public/css/list.scss'; @import './public/css/list.scss';
</style> </style>
<style scoped> <style scoped>
>>>.uni-tag--primary.uni-tag--inverted { ::v-deep .uni-tag--primary.uni-tag--inverted {
background-color: #f5f5f5 !important; background-color: #f5f5f5 !important;
} }
/deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box { ::v-deep .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
max-height: unset !important; max-height: unset !important;
} }
</style> </style>

View File

@@ -1,7 +1,8 @@
{ {
"description": "项目配置文件", "description": "项目配置文件",
"packOptions": { "packOptions": {
"ignore": [] "ignore": [],
"include": []
}, },
"setting": { "setting": {
"urlCheck": true, "urlCheck": true,
@@ -37,20 +38,20 @@
"userConfirmedBundleSwitch": false, "userConfirmedBundleSwitch": false,
"packNpmManually": false, "packNpmManually": false,
"packNpmRelationList": [], "packNpmRelationList": [],
"minifyWXSS": true "minifyWXSS": true,
"compileWorklet": false,
"minifyWXML": true,
"localPlugins": false,
"disableUseStrict": false,
"useCompilerPlugins": false,
"condition": false,
"swc": false,
"disableSWC": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.16.1", "libVersion": "3.12.1",
"appid": "wx29215aa1bd97bbd6", "appid": "wx29215aa1bd97bbd6",
"projectname": "niushop_b2c_v4_uniapp", "projectname": "niushop_b2c_v4_uniapp",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"staticServerOptions": {
"baseURL": "",
"servePath": ""
},
"isGameTourist": false, "isGameTourist": false,
"condition": { "condition": {
"search": { "search": {
@@ -71,5 +72,7 @@
"miniprogram": { "miniprogram": {
"list": [] "list": []
} }
} },
"simulatorPluginLibVersion": {},
"editorSetting": {}
} }

View File

@@ -0,0 +1,24 @@
{
"libVersion": "3.12.1",
"projectname": "niushop_b2c_v4_uniapp",
"condition": {},
"setting": {
"urlCheck": true,
"coverView": true,
"lazyloadPlaceholderEnable": false,
"skylineRenderEnable": false,
"preloadBackgroundData": false,
"autoAudits": false,
"useApiHook": true,
"useApiHostProcess": true,
"showShadowRootInWxmlPanel": true,
"useStaticServer": false,
"useLanDebug": false,
"showES6CompileOption": false,
"compileHotReLoad": true,
"checkInvalidKey": true,
"ignoreDevUnusedFiles": true,
"bigPackageSizeSupport": false,
"useIsolateContext": true
}
}