feat(i18n): 剩余15页全量接入中英(登录/注册/扫码/绑定/佩戴/扫描/治疗/订阅/帮助等)
- 3 个并行 agent 各管 5 页,互不重叠命名空间 - 全 App 18 页均 i18n.bind,22 命名空间/400 键中英对齐 - 动态文案(时长/天数/价格/区域)JS 内 i18n.t 计算;区域标签复用 common.regions
这个提交包含在:
@@ -1,6 +1,7 @@
|
||||
var ble = require('../../services/ble')
|
||||
var api = require('../../utils/api')
|
||||
var commandSync = require('../../services/command-sync')
|
||||
var i18n = require('../../i18n/index')
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
@@ -16,19 +17,31 @@ Page({
|
||||
paused: false,
|
||||
completed: false,
|
||||
startedAt: 0,
|
||||
regionText: '全区域',
|
||||
regionText: '',
|
||||
fittingLost: false,
|
||||
deviceFault: false
|
||||
},
|
||||
|
||||
_getRegionText: function (regionMask) {
|
||||
var REGION_MAP = {1:'右区', 2:'左区', 4:'上区', 8:'中区', 16:'下区', 32:'左上区', 64:'右上区'}
|
||||
if (regionMask === 0x7F) return '全区域'
|
||||
var REGION_MAP = {
|
||||
1: 'common.regions.right',
|
||||
2: 'common.regions.left',
|
||||
4: 'common.regions.top',
|
||||
8: 'common.regions.middle',
|
||||
16: 'common.regions.bottom',
|
||||
32: 'treating.regionTopLeft',
|
||||
64: 'treating.regionTopRight'
|
||||
}
|
||||
if (regionMask === 0x7F) return i18n.t('treating.allRegions')
|
||||
var names = []
|
||||
for (var bit in REGION_MAP) {
|
||||
if (regionMask & parseInt(bit)) names.push(REGION_MAP[bit])
|
||||
if (regionMask & parseInt(bit)) names.push(i18n.t(REGION_MAP[bit]))
|
||||
}
|
||||
return names.length > 0 ? names.join('+') : '全区域'
|
||||
return names.length > 0 ? names.join('+') : i18n.t('treating.allRegions')
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
i18n.bind(this)
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
@@ -91,10 +104,10 @@ Page({
|
||||
if (this.data.completed) return
|
||||
if (data.fitting === 0 && !this.data.fittingLost) {
|
||||
this.setData({ fittingLost: true, paused: true })
|
||||
wx.showToast({ title: '检测到离肤,请重新佩戴设备', icon: 'none', duration: 3000 })
|
||||
wx.showToast({ title: i18n.t('treating.fittingLost'), icon: 'none', duration: 3000 })
|
||||
} else if (data.fitting === 1 && this.data.fittingLost) {
|
||||
this.setData({ fittingLost: false, paused: false })
|
||||
wx.showToast({ title: '已重新贴合,继续使用', icon: 'success', duration: 2000 })
|
||||
wx.showToast({ title: i18n.t('treating.fittingRestored'), icon: 'success', duration: 2000 })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -112,8 +125,8 @@ Page({
|
||||
this.setData({ deviceFault: true })
|
||||
var self = this
|
||||
wx.showModal({
|
||||
title: '设备故障',
|
||||
content: '设备上报故障,已自动停止。',
|
||||
title: i18n.t('treating.faultTitle'),
|
||||
content: i18n.t('treating.faultContent'),
|
||||
showCancel: false,
|
||||
complete: function () { self.finishAsComplete() }
|
||||
})
|
||||
@@ -136,8 +149,8 @@ Page({
|
||||
if (self.data.battery > 0 && self.data.battery <= 5) {
|
||||
clearInterval(timer)
|
||||
wx.showModal({
|
||||
title: '电量过低',
|
||||
content: '设备电量不足5%,已自动停止。请及时充电。',
|
||||
title: i18n.t('treating.lowBatteryTitle'),
|
||||
content: i18n.t('treating.lowBatteryContent'),
|
||||
showCancel: false,
|
||||
complete: function () { self.finishAsComplete() }
|
||||
})
|
||||
@@ -146,7 +159,7 @@ Page({
|
||||
|
||||
if (self.data.battery > 0 && self.data.battery <= 10 && !self._lowBatteryWarned) {
|
||||
self._lowBatteryWarned = true
|
||||
wx.showToast({ title: '电量低,请及时充电', icon: 'none', duration: 3000 })
|
||||
wx.showToast({ title: i18n.t('treating.lowBatteryWarn'), icon: 'none', duration: 3000 })
|
||||
}
|
||||
|
||||
if (remaining <= 0) {
|
||||
@@ -262,8 +275,8 @@ Page({
|
||||
|
||||
onException: function (err) {
|
||||
wx.showModal({
|
||||
title: '设备异常',
|
||||
content: err.error_msg || '使用过程中出现异常',
|
||||
title: i18n.t('treating.exceptionTitle'),
|
||||
content: err.error_msg || i18n.t('treating.exceptionContent'),
|
||||
showCancel: false,
|
||||
complete: function () {
|
||||
wx.navigateBack()
|
||||
@@ -274,7 +287,7 @@ Page({
|
||||
onDisconnect: function () {
|
||||
this.setData({ paused: true })
|
||||
wx.showToast({
|
||||
title: '设备连接断开,正在重连...',
|
||||
title: i18n.t('treating.disconnected'),
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
@@ -283,7 +296,7 @@ Page({
|
||||
onReconnect: function () {
|
||||
this.setData({ paused: false })
|
||||
wx.showToast({
|
||||
title: '设备已重新连接',
|
||||
title: i18n.t('treating.reconnected'),
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
@@ -296,8 +309,8 @@ Page({
|
||||
this._localTimer = null
|
||||
}
|
||||
wx.showModal({
|
||||
title: '连接丢失',
|
||||
content: '设备蓝牙连接已断开,无法恢复。本次使用数据将保存。',
|
||||
title: i18n.t('treating.reconnectFailedTitle'),
|
||||
content: i18n.t('treating.reconnectFailedContent'),
|
||||
showCancel: false,
|
||||
complete: function () {
|
||||
self.finishAsComplete()
|
||||
@@ -312,8 +325,8 @@ Page({
|
||||
onStop: function () {
|
||||
var self = this
|
||||
wx.showModal({
|
||||
title: '结束使用',
|
||||
content: '确定要提前结束本次使用吗?',
|
||||
title: i18n.t('treating.stopTitle'),
|
||||
content: i18n.t('treating.stopContent'),
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
ble.stopTreatment().then(function (res) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<view class="page">
|
||||
<view class="page-header page-header-blue" style="padding-top: {{statusBarHeight + 24}}px;">
|
||||
<view class="nav-back nav-back-light" bindtap="onBack">‹ 返回</view>
|
||||
<view class="page-header-title">使用中</view>
|
||||
<view class="page-header-subtitle">正在使用...</view>
|
||||
<view class="nav-back nav-back-light" bindtap="onBack">‹ {{i18n.common.back}}</view>
|
||||
<view class="page-header-title">{{i18n.treating.title}}</view>
|
||||
<view class="page-header-subtitle">{{i18n.treating.subtitle}}</view>
|
||||
</view>
|
||||
|
||||
<view class="page-content">
|
||||
<view class="countdown-area">
|
||||
<text class="countdown-time">{{remainingText}}</text>
|
||||
<view class="countdown-label">剩余时间</view>
|
||||
<view class="countdown-label">{{i18n.treating.remainingLabel}}</view>
|
||||
</view>
|
||||
|
||||
<view class="progress-bar">
|
||||
@@ -16,17 +16,17 @@
|
||||
</view>
|
||||
|
||||
<view class="mode-tag-area">
|
||||
<text class="mode-tag">{{mode === 1 ? '✨ 智能模式' : '🔄 普通模式'}} · {{regionText}}</text>
|
||||
<text class="mode-tag">{{mode === 1 ? i18n.treating.smartMode : i18n.treating.normalMode}} · {{regionText}}</text>
|
||||
</view>
|
||||
|
||||
<view class="relax-card">
|
||||
<text class="relax-icon">💆</text>
|
||||
<view class="relax-text">
|
||||
<text>请放松心情</text>
|
||||
<text>享受美好时光</text>
|
||||
<text>{{i18n.treating.relax1}}</text>
|
||||
<text>{{i18n.treating.relax2}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="btn-primary btn-primary-red" bindtap="onStop">停止使用</button>
|
||||
<button class="btn-primary btn-primary-red" bindtap="onStop">{{i18n.treating.stopBtn}}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
在新工单中引用
屏蔽一个用户