chore: remove all mock/debug code for production release
Miniprogram: - ENV switched to 'prod' (disables __DEV__ flag) - Deleted mock.js and test-ble-frame.js - Removed mockBind/mockPurchase from api.js - Removed all debug UI panels and onMock* handlers from 6 pages - Removed mock purchase fallback in subscribe-plans - Removed SIMPLE PERIPHERAL dev board from BLE scan Server: - Removed /device/mock-bind route - Removed /subscription/mock-purchase route - Removed dev_openid fallback in wechat.js - Removed mockBind() from binding.dao.js - Removed mock fallback in purchase endpoint - NODE_ENV default changed to 'production' Admin: - ENV switched to 'prod' All mock code preserved in 'test' branch for future development use.
这个提交包含在:
@@ -1,6 +1,4 @@
|
||||
var ble = require('../../services/ble')
|
||||
var config = require('../../config/env')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
@@ -9,8 +7,7 @@ Page({
|
||||
regions: 0x7F,
|
||||
regionData: [],
|
||||
timeout: false,
|
||||
error: '',
|
||||
devMode: false
|
||||
error: ''
|
||||
},
|
||||
|
||||
onBack: function () {
|
||||
@@ -25,8 +22,7 @@ Page({
|
||||
var app = getApp()
|
||||
this.setData({
|
||||
statusBarHeight: app.globalData.statusBarHeight,
|
||||
regions: parseInt(options.regions) || 0x7F,
|
||||
devMode: config.__DEV__ || false
|
||||
regions: parseInt(options.regions) || 0x7F
|
||||
})
|
||||
this.startScan()
|
||||
},
|
||||
@@ -93,15 +89,4 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onMockScanDone: function () {
|
||||
var self = this
|
||||
if (self._progressTimer) clearInterval(self._progressTimer)
|
||||
var mask = parseInt(self.data.regions) || 0x7F
|
||||
wx.redirectTo({
|
||||
url: '/pages/treating/treating?regions=' + mask +
|
||||
'&wavelength=2' +
|
||||
'&duration=600000' +
|
||||
'&mode=1'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -17,11 +17,6 @@
|
||||
<view class="scan-hint">请将面罩对准面部</view>
|
||||
<view class="scan-hint" style="font-size:24rpx;color:#999;margin-top:8rpx;">连接设备后可获取皮肤数据</view>
|
||||
|
||||
<view class="debug-actions" wx:if="{{devMode}}">
|
||||
<view class="debug-label">🔧 调试工具</view>
|
||||
<button class="btn-secondary btn-sm" bindtap="onMockScanDone">模拟扫描完成</button>
|
||||
</view>
|
||||
|
||||
<view class="scan-progress" wx:if="{{scanning}}">
|
||||
正在扫描... <text class="highlight">{{regionData.length || 3}}</text> 个区域
|
||||
</view>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var ble = require('../../services/ble')
|
||||
var http = require('../../utils/request')
|
||||
var config = require('../../config/env')
|
||||
var app = getApp()
|
||||
var SCAN_TIMEOUT = 15000
|
||||
|
||||
@@ -11,7 +10,6 @@ Page({
|
||||
bindToken: '',
|
||||
state: 'scanning',
|
||||
error: '',
|
||||
devMode: false
|
||||
},
|
||||
|
||||
onBack: function () {
|
||||
@@ -26,8 +24,7 @@ Page({
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
||||
this.setData({
|
||||
deviceId: options.device_id || '',
|
||||
bindToken: options.bind_token || '',
|
||||
devMode: config.__DEV__ || false
|
||||
bindToken: options.bind_token || ''
|
||||
})
|
||||
this.startBleConnect()
|
||||
},
|
||||
@@ -110,24 +107,4 @@ Page({
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
onMockConnect: function () {
|
||||
var self = this
|
||||
clearTimeout(this._scanTimer)
|
||||
ble.stopScan()
|
||||
self.setData({ state: 'binding' })
|
||||
http.post('/api/v1/device/mock-bind', {
|
||||
device_id: self.data.deviceId
|
||||
}).then(function () {
|
||||
self.setData({ state: 'done' })
|
||||
wx.redirectTo({
|
||||
url: '/pages/bind-success/bind-success?device_id=' + self.data.deviceId
|
||||
})
|
||||
}).catch(function (err) {
|
||||
self.setData({ state: 'error', error: err.message || '模拟绑定失败' })
|
||||
})
|
||||
},
|
||||
|
||||
onMockBindSuccess: function () {
|
||||
this.onMockConnect()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -28,10 +28,5 @@
|
||||
<button class="retry-btn" bindtap="onRetry">重试</button>
|
||||
</view>
|
||||
|
||||
<view class="debug-actions" wx:if="{{devMode}}">
|
||||
<view class="debug-label">🔧 调试工具</view>
|
||||
<button class="btn-secondary btn-sm" bindtap="onMockConnect">模拟连接成功</button>
|
||||
<button class="btn-secondary btn-sm" bindtap="onMockBindSuccess">模拟绑定成功</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
var ble = require('../../services/ble')
|
||||
var api = require('../../utils/api')
|
||||
var config = require('../../config/env')
|
||||
var app = getApp()
|
||||
|
||||
Page({
|
||||
@@ -14,14 +13,9 @@ Page({
|
||||
bleState: 'disconnected',
|
||||
hasDevice: false,
|
||||
deviceInfo: null,
|
||||
devMode: false,
|
||||
loading: true
|
||||
},
|
||||
|
||||
onLoad: function () {
|
||||
this.setData({ devMode: config.__DEV__ || false })
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.checkState()
|
||||
this._onStatus = this.onBleStatus.bind(this)
|
||||
@@ -173,26 +167,6 @@ Page({
|
||||
wx.navigateTo({ url: '/pages/wear-check/wear-check' })
|
||||
},
|
||||
|
||||
onMockBind: function () {
|
||||
var self = this
|
||||
wx.showModal({
|
||||
title: '模拟绑定',
|
||||
editable: true,
|
||||
placeholderText: '输入设备编号(需先在后台创建)',
|
||||
success: function (res) {
|
||||
if (res.confirm && res.content) {
|
||||
var deviceId = res.content.trim()
|
||||
api.mockBind(deviceId).then(function () {
|
||||
wx.showToast({ title: '模拟绑定成功', icon: 'success' })
|
||||
self.checkState()
|
||||
}).catch(function (err) {
|
||||
wx.showToast({ title: err.message || '绑定失败', icon: 'none' })
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onViewSubscription: function () {
|
||||
wx.navigateTo({ url: '/pages/subscribe-plans/subscribe-plans' })
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
<text class="empty-icon">📱</text>
|
||||
<view class="empty-text">还没有绑定设备</view>
|
||||
<button class="btn-primary mt-30" bindtap="onAddDevice">扫码添加设备</button>
|
||||
<view class="debug-actions" wx:if="{{devMode}}">
|
||||
<view class="debug-label">🔧 调试工具</view>
|
||||
<button class="btn-secondary btn-sm" bindtap="onMockBind">模拟绑定设备</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var api = require('../../utils/api')
|
||||
var config = require('../../config/env')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
@@ -163,17 +162,12 @@ Page({
|
||||
var self = this
|
||||
self.setData({ purchasing: true })
|
||||
api.purchase(plan.key).then(function (data) {
|
||||
if (data.mock || !data.payment_params) {
|
||||
// Dev fallback: use mock purchase
|
||||
return api.mockPurchase(plan.key).then(function () {
|
||||
self.setData({ purchasing: false })
|
||||
wx.showToast({ title: '支付成功', icon: 'success' })
|
||||
setTimeout(function () {
|
||||
wx.redirectTo({ url: '/pages/subscribe-success/subscribe-success?plan=' + plan.key })
|
||||
}, 1000)
|
||||
})
|
||||
if (!data.payment_params) {
|
||||
self.setData({ purchasing: false })
|
||||
wx.showToast({ title: '支付服务暂不可用', icon: 'none' })
|
||||
return
|
||||
}
|
||||
// Real payment
|
||||
|
||||
var params = data.payment_params
|
||||
self._currentOrderId = data.order_id
|
||||
wx.requestPayment({
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
var ble = require('../../services/ble')
|
||||
var api = require('../../utils/api')
|
||||
var commandSync = require('../../services/command-sync')
|
||||
var config = require('../../config/env')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
@@ -18,7 +16,6 @@ Page({
|
||||
paused: false,
|
||||
completed: false,
|
||||
startedAt: 0,
|
||||
devMode: false,
|
||||
regionText: '全脸护理',
|
||||
},
|
||||
|
||||
@@ -34,7 +31,7 @@ Page({
|
||||
|
||||
onLoad: function (options) {
|
||||
var app = getApp()
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight, devMode: config.__DEV__ || false })
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
||||
this._deviceId = ble.getDeviceId() || (app.globalData.currentDevice && app.globalData.currentDevice.device_id) || ''
|
||||
var regions = parseInt(options.regions) || 0x7F
|
||||
this.setData({
|
||||
@@ -259,7 +256,4 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onMockComplete: function () {
|
||||
this.finishAsComplete()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -27,11 +27,6 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="debug-actions" wx:if="{{devMode}}">
|
||||
<view class="debug-label">🔧 调试工具</view>
|
||||
<button class="btn-secondary btn-sm" bindtap="onMockComplete">模拟护理完成</button>
|
||||
</view>
|
||||
|
||||
<button class="btn-primary btn-primary-red" bindtap="onStop">停止护理</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
var ble = require('../../services/ble')
|
||||
var config = require('../../config/env')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
@@ -16,8 +14,7 @@ Page({
|
||||
subDays: 6,
|
||||
fixedDurationMs: 600000,
|
||||
submitting: false,
|
||||
error: '',
|
||||
devMode: false
|
||||
error: ''
|
||||
},
|
||||
|
||||
onBack: function () {
|
||||
@@ -30,7 +27,7 @@ Page({
|
||||
|
||||
onLoad: function () {
|
||||
var app = getApp()
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight, devMode: config.__DEV__ || false })
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
||||
this.checkSubscription()
|
||||
},
|
||||
|
||||
@@ -109,17 +106,4 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onMockStart: function () {
|
||||
var mask = 0
|
||||
this.data.regions.forEach(function (r) {
|
||||
if (r.checked) mask |= r.mask
|
||||
})
|
||||
if (mask === 0) mask = 0x7F
|
||||
wx.redirectTo({
|
||||
url: '/pages/treating/treating?regions=' + mask +
|
||||
'&wavelength=2' +
|
||||
'&duration=' + this.data.fixedDurationMs +
|
||||
'&mode=' + this.data.selectedMode
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -38,10 +38,5 @@
|
||||
</button>
|
||||
|
||||
<view class="error-text" wx:if="{{error}}">{{error}}</view>
|
||||
|
||||
<view class="debug-actions" wx:if="{{devMode}}">
|
||||
<view class="debug-label">🔧 调试工具</view>
|
||||
<button class="btn-secondary btn-sm" bindtap="onMockStart">模拟开始护理(跳过BLE)</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
var ble = require('../../services/ble')
|
||||
var config = require('../../config/env')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
checking: false,
|
||||
result: null,
|
||||
error: '',
|
||||
devMode: false,
|
||||
battery: 0,
|
||||
connected: false
|
||||
},
|
||||
@@ -22,7 +19,7 @@ Page({
|
||||
|
||||
onLoad: function () {
|
||||
var app = getApp()
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight, devMode: config.__DEV__ || false })
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
||||
var device = app.globalData.currentDevice || {}
|
||||
this.setData({
|
||||
battery: device.battery || 0,
|
||||
@@ -108,7 +105,4 @@ Page({
|
||||
}, 500)
|
||||
},
|
||||
|
||||
onMockWearOk: function () {
|
||||
this.setData({ checking: false, result: 'ok' })
|
||||
}
|
||||
})
|
||||
|
||||
@@ -41,10 +41,5 @@
|
||||
</view>
|
||||
|
||||
<button wx:if="{{result === 'ok'}}" class="btn-primary mt-30" bindtap="onNext">设置护理参数</button>
|
||||
|
||||
<view class="debug-actions" wx:if="{{devMode}}">
|
||||
<view class="debug-label">🔧 调试工具</view>
|
||||
<button class="btn-secondary btn-sm" bindtap="onMockWearOk">模拟佩戴确认</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
在新工单中引用
屏蔽一个用户