同步代码

This commit is contained in:
GaoHao
2025-02-07 14:49:20 +08:00
commit 0740c3f349
1141 changed files with 167372 additions and 0 deletions

225
pageDevice/lite/edit.vue Normal file
View File

@@ -0,0 +1,225 @@
<template>
<view class="page-wrapper jeepay-edit-form">
<JeepayCustomNavbar :title="vdata.isAdd ? '绑定如意Lite' : '修改如意Lite信息'" backCtrl="back" />
<uni-forms ref="formRef" :rules="rules" :model="vdata.formData" :label-width="120">
<uni-forms-item v-if="vdata.isAdd" required label="设备号" name="deviceNo">
<view class="scan-wrapper">
<uni-easyinput v-model="vdata.formData.deviceNo" placeholder="请输入设备号" :inputBorder="false"></uni-easyinput>
<image src="/pageDevice/static/devIconImg/icon-scan-code.svg" mode="scaleToFill" @tap="scanCode" />
</view>
</uni-forms-item>
<uni-forms-item required label="设备名称" name="deviceName">
<uni-easyinput v-model="vdata.formData.deviceName" placeholder="请输入设备名称" :inputBorder="false"></uni-easyinput>
</uni-forms-item>
<uni-forms-item required label="选择应用" name="appId">
<JeepayBizsPopupView :hasTitle="false" bizType="mchApp" v-model:value="vdata.formData.appId"
:showName="vdata.bindAppName" />
</uni-forms-item>
<uni-forms-item required label="选择门店" name="storeId">
<JeepayBizsPopupView :hasTitle="false" bizType="store" v-model:value="vdata.formData.storeId"
:showName="vdata.bindStoreName" />
</uni-forms-item>
<JeepayTableListItem title="状态" subtitle="状态禁用后, 设备将无法使用" v-if="!vdata.formData.deviceId">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.formData.state" :showSwitchType="true" :confirm='false' />
</template>
</JeepayTableListItem>
</uni-forms>
<view class="confirm-wrapper">
<Button @tap="confirmFunc">{{ vdata.deviceId ? '确认修改' : '确认创建' }}</Button>
</view>
</view>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { reqLoad, API_URL_SYS_DEVICE_LIST } from '@/http/apiManager.js'
import infoBox from '@/commons/utils/infoBox.js';
import go from '@/commons/utils/go.js'
import formUtil from '@/commons/utils/formUtil.js'
import emit from '@/commons/utils/emit.js'
const formRef = ref()
onLoad((options) => {
// 修改页面
if (options.deviceId) {
vdata.isAdd = false
vdata.deviceId = options.deviceId
reqLoad.getById(API_URL_SYS_DEVICE_LIST, vdata.deviceId).then(({ bizData }) => {
vdata.formData = bizData
vdata.bindAppName = bizData.appName
vdata.bindStoreName = bizData.storeName
})
}
// 参数赋值。
if (options.deviceNo) {
vdata.formData.deviceNo = options.deviceNo
}
})
// 扫码
const scanCode = () => {
uni.scanCode({
success: ({ result }) => {
vdata.formData.deviceNo = result
},
fail: (err) => {
infoBox.showErrorToast('扫码失败')
},
})
}
const rules = {
appId: {
rules: [formUtil.rules.requiredSelect('应用')],
},
storeId: {
rules: [formUtil.rules.requiredSelect('门店')],
},
deviceNo: {
rules: [formUtil.rules.requiredInput('')],
},
deviceName: {
rules: [formUtil.rules.requiredInput('')],
},
}
const vdata = reactive({
deviceId: null, // 新建 or 修改
isAdd: true, // 是否新增页面
bindAppName: '',
bindStoreName: '',
// 表单数据
formData: {
state: 1 // 默认启用
}
})
function confirmFunc () {
formUtil.validate(formRef.value).then(() => {
let reqData = Object.assign({}, vdata.formData)
reqData.deviceType = 7 // 1-云喇叭, 2-云打印, 3-扫码pos, 4-智能pos, 5-收银插件 7-如意lite
return reqLoad.addOrUpdate(vdata.deviceId, API_URL_SYS_DEVICE_LIST, reqData)
})
.then(({ bizData }) => {
emit.pageEmit(emit.ENAME_REF_AUTOPOS_LIST) // 更新列表
go.back(1, emit.ENAME_REF_AUTOPOS_DETAIL) // 返回详情 && 更新详情 && search
})
}
</script>
<style lang="scss">
input {
font-size: 32rpx;
}
.selected-sex {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 32rpx;
color: #b3b3b3;
image {
flex-shrink: 0;
width: 120rpx;
height: 120rpx;
}
}
.line {
margin-bottom: 20rpx;
}
.confirm-wrapper {
padding: 50rpx 30rpx;
.confirm-button {
height: 110rpx;
color: #fff;
border-radius: 20rpx;
background: $jeepay-bg-primary;
}
}
.align-top {
align-items: flex-start;
padding: 40rpx 0;
height: auto;
min-height: auto;
image {
width: 120rpx;
height: 40rpx;
transform: rotate(90deg);
}
}
.border-tb {
position: relative;
&::after {
content: '';
position: absolute;
top: 0;
right: 0;
z-index: 10;
width: 90vw;
height: 1rpx;
background-color: #ededed;
}
&::before {
content: '';
position: absolute;
bottom: 0;
right: 0;
z-index: 10;
width: 90vw;
height: 1rpx;
background-color: #ededed;
}
}
.scan-wrapper {
display: flex;
align-items: center;
input {
flex: 1;
}
image {
width: 120rpx;
height: 120rpx;
}
}
</style>

68
pageDevice/lite/index.vue Normal file
View File

@@ -0,0 +1,68 @@
<template>
<CommonPageByDevice
ref="commonPageByDeviceRef"
navTitle="如意Lite管理"
searchTitle="搜索设备名称、编号"
searchType="device"
:searchParams="{deviceType: 7}"
:bottomBtnTitle="ak.ent.has('ENT_DEVICE_AUTO_POS_ADD') ? '绑定设备' : null "
@bottomBtnClickFunc="bottomBtnClickFunc"
:reqTableDataFunc="reqTableDataFunc"
>
</CommonPageByDevice>
<JSinglePopup ref="jsinglePopupRef" :list="codeBindList" activeColor="#FF5B4C" />
</template>
<script setup>
import { reactive, ref } from 'vue'
import { onReachBottom, onUnload } from '@dcloudio/uni-app'
import emit from '@/commons/utils/emit.js'
import CommonPageByDevice from '../commons/CommonPageByDevice.vue'
import { reqLoad, API_URL_SYS_DEVICE_LIST } from '@/http/apiManager.js'
import go from '@/commons/utils/go.js'
import DeviceCommonsRender from '@/pages/list/render/DeviceCommonsRender.vue'
import ak from '@/commons/utils/ak.js'
const jsinglePopupRef = ref(null)
const commonPageByDeviceRef = ref()
// 监听 更新事件
onUnload( () => uni.$off(emit.ENAME_REF_AUTOPOS_LIST) )
uni.$on(emit.ENAME_REF_AUTOPOS_LIST, function(data){
commonPageByDeviceRef.value.refTable(true)
})
const reqTableDataFunc = (params) => {
params.deviceType = 7 // 1-云喇叭, 2-云打印, 3-扫码pos, 4-智能pos, 5-收银插件 7 如意lite
return reqLoad.list(API_URL_SYS_DEVICE_LIST, params)
}
function bottomBtnClickFunc(){
jsinglePopupRef.value.open()
}
const codeBindList = [
{ label: '扫码绑定', value: 'scanCode', fun: () => {
uni.scanCode().then(({ result }) => {
go.to('PAGES_LITE_EDIT', { deviceNo: result })
})
}
},
{ label: '手动绑定', value: 'handBind', fun: () => {
go.to('PAGES_LITE_EDIT')
}
},
]
onReachBottom(() => {})
</script>
<style lang="scss" scoped>
</style>

160
pageDevice/lite/view.vue Normal file
View File

@@ -0,0 +1,160 @@
<template>
<JeepayBackground :bgColorStyle="{}">
<JeepayCustomNavbar textColor="#fff"
bgDefaultColor="linear-gradient(270deg, rgba(72, 192, 255, 1) 0%, rgba(51, 157, 255, 1) 100%)" title="如意Lite详情"
backCtrl="back" />
<JeepayTableListItem viewClass="list-item-by-detail" logo="/pageDevice/static/detailsLislImg/lite-white.svg"
:title="vdata.record.deviceName" :subtitle="vdata.record.deviceNo" :moreBtnList="list" />
<JeepayCard editText="编辑信息" @editTap="go.to('PAGES_LITE_EDIT', { deviceId: vdata.record.deviceId })">
<JeepayDescview>
<JeepayDescviewItem title="设备名称" :desc="vdata.record.deviceName" />
<JeepayDescviewItem title="绑定应用" :desc="vdata.record.appId" />
<JeepayDescviewItem title="绑定门店" :desc="vdata.record.storeName" />
</JeepayDescview>
</JeepayCard>
<JeepayCard title="其他设置" viewStyle="margin-top: 30rpx;">
<JeepayTableListItem title="终端状态" subtitle="状态禁用后,当前终端将无法使用">
<template #titleRight>
<JeepayStateSwitch v-model:state="vdata.record.state" :showSwitchType="true" :updateStateFunc="updateState" />
</template>
</JeepayTableListItem>
</JeepayCard>
<JeepayCard :title="`${!vdata.record.alipayBindState ? '' : '已'}绑定至蚂蚁店铺`" @clickTitle="bindingAlitStore"
viewStyle="margin-top: 30rpx;" :isTitleBorder="vdata.record.alipayBindState">
<template #titleRight>
<image class="selected-qrcId" src="/static/iconImg/icon-arrow-black.svg" mode="scaleToFill"
v-if="!vdata.record.alipayBindState" />
</template>
<JeepayTableListItem :title="vdata.aliStoreInfo.storeName" :subtitle="vdata.aliStoreInfo.alipayShopId"
v-if="vdata.record.alipayBindState" />
<view class="un-binding" hover-stay-time="50" hover-class="hover-button" v-if="vdata.record.alipayBindState"
@tap="unBindIng">解绑蚂蚁店铺</view>
</JeepayCard>
</JeepayBackground>
<JeepayPopupConfirm ref="jeepayPopupConfirmRef" />
<JeepayBizinfoSelect ref="refSelectedStore" :params="{alipayShopStatus: 99}" bizType="store" />
</template>
<script setup>
import { reactive, ref } from 'vue'
import { onLoad, onUnload } from '@dcloudio/uni-app'
import { reqLoad, API_URL_SYS_DEVICE_LIST, $deviceUnbind, API_URL_MCH_STORE_LIST, $BindLite } from '@/http/apiManager.js'
import go from '@/commons/utils/go.js'
import emit from '@/commons/utils/emit.js'
import infoBox from '@/commons/utils/infoBox.js'
const jeepayPopupConfirmRef = ref()
onLoad((options) => {
refData(options.deviceId)
})
const refSelectedStore = ref(null)
const vdata = reactive({
record: {},
aliStoreInfo: {}
})
// 监听 更新事件
onUnload(() => uni.$off(emit.ENAME_REF_AUTOPOS_DETAIL))
uni.$on(emit.ENAME_REF_AUTOPOS_DETAIL, function (data) {
refData(vdata.record.deviceId)
})
function refData (id) {
reqLoad.getById(API_URL_SYS_DEVICE_LIST, id).then(({ bizData }) => {
vdata.record = bizData
getAliStoreInfo()
})
}
function deleteFunc () {
jeepayPopupConfirmRef.value.open('您确认解绑设备吗?', { confirmColor: '#FF5B4C' }).then(() => {
$deviceUnbind(vdata.record.deviceId).then(() => {
infoBox.showSuccessToast('解绑成功')
return go.back(1, emit.ENAME_REF_AUTOPOS_LIST)
})
})
}
const list = reactive([
{ label: '解绑设备', value: 'delete', color: 'red', fun: deleteFunc },
{ label: '编辑设备', value: 'edit', fun: ()=>{
go.to('PAGES_LITE_EDIT', { deviceId: vdata.record.deviceId })
} },
])
// 更新状态
function updateState (state) {
return reqLoad.updateById(API_URL_SYS_DEVICE_LIST, vdata.record.deviceId, { state: state }).then(() => {
emit.refPageAndSearchEmit(emit.ENAME_REF_AUTOPOS_LIST) // 修改列表页面。
infoBox.showSuccessToast('修改成功')
})
}
// 绑定蚂蚁门店
const bindingAlitStore = () => {
refSelectedStore.value.open().then(res => {
const data = {
alipayBindState: 1,
deviceId: vdata.record.deviceId,
storeId: res.storeId,
}
jeepayPopupConfirmRef.value.open(`您确认要把[${res.storeName}]绑定至蚂蚁店铺吗?`).then(r => {
$BindLite(data).then(res => {
infoBox.showSuccessToast('蚂蚁店铺绑定成功')
refData(vdata.record.deviceId)
})
}).catch(er=>{
bindingAlitStore()
})
})
}
// 获取蚂蚁店铺信息
const getAliStoreInfo = () => {
reqLoad.list(API_URL_MCH_STORE_LIST, { pageSize: '-1', alipayShopStatus: 99 }).then(({ bizData }) => {
vdata.aliStoreInfo = bizData.records.find(v => v.storeId == vdata.record.storeId)
})
}
// 解绑店铺
const unBindIng = () => {
const data = {
alipayBindState: 0,
deviceId: vdata.record.deviceId,
storeId: vdata.record.storeId,
}
jeepayPopupConfirmRef.value.open('您确认要解绑蚂蚁店铺吗?', { confirmColor: '#FF5B4C' }).then(res => {
$BindLite(data).then(res => {
infoBox.showSuccessToast('蚂蚁店铺解绑成功')
refData(vdata.record.deviceId)
})
})
}
</script>
<style lang="scss" scoped>
.default-image {
width: 50rpx;
height: 50rpx;
}
.selected-qrcId {
width: 40rpx;
height: 40rpx;
transform: rotate(90deg);
}
.un-binding {
display: flex;
justify-content: center;
align-items: center;
margin: 15px;
margin-top: 0;
height: 110rpx;
background-color: rgba($color: #ec4444, $alpha: 0.1);
color: #ec4444;
border-radius: 10rpx;
}
.hover-button {
opacity: 0.5;
}
</style>