5 Commits
wwz ... gh

5 changed files with 174 additions and 7 deletions

143
App.vue
View File

@@ -6,8 +6,9 @@ App.vue本身不是页面这里不能编写视图元素也就是没有<tem
import { import {
onLaunch onLaunch
} from '@dcloudio/uni-app'; } from '@dcloudio/uni-app';
import { getFindBySource } from '@/http/yskApi/version.js'
onLaunch(() => { onLaunch(() => {
let that = this
uni.hideTabBar() uni.hideTabBar()
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
const updateManager = wx.getUpdateManager() // 小程序版本更新管理器 const updateManager = wx.getUpdateManager() // 小程序版本更新管理器
@@ -23,6 +24,146 @@ App.vue本身不是页面这里不能编写视图元素也就是没有<tem
// 新版本下载失败 // 新版本下载失败
}) })
// #endif // #endif
//#ifdef APP-PLUS
//获取当前系统版本信息
plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
//请求后台接口 解析数据 对比版本
console.log("widgetInfo==",widgetInfo)
getFindBySource({source:'APP'}).then(res => {
console.log("selectNewApp==",res)
console.log("version===",res.url && widgetInfo.version < res.version)
if (res.url && widgetInfo.version < res.version) {
console.log("version===222")
let downloadLink = res.url;
// let downloadLink = "https://short-video.hnsiyao.cn/app/sy-duanju.apk";
console.log(downloadLink)
// let androidLink = res.androidWgtUrl;
// let iosLink = res.iosWgtUrl;
let ready = false;
// 校验是否强制升级
if (res.isUp == 1) {
uni.showModal({
showCancel: false,
title: '发现新版本',
confirmText: '立即更新',
content: res.message,
success: res => {
if (res.confirm) {
uni.showLoading('下载中...');
if (uni.getSystemInfoSync().platform ==
'android') {
uni.downloadFile({
url: downloadLink,
success: downloadResult => {
if (downloadResult.statusCode === 200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
entry.getParent(_oldFile=>{
entry.moveTo(_oldFile,'.apk',newFilePath=>{
console.log('newFilePath',newFilePath.fullPath)
plus.runtime
.install(newFilePath.fullPath, { force: false },
d => {
console
.log(
'install success...'
);
plus.runtime
.restart();
},
e => {
console.log(e)
console
.error(
'install fail...'
);
}
);
})
})
})
}
}
});
}
if (uni.getSystemInfoSync().platform ==
'ios') {
plus.runtime.openURL(downloadLink, function(
res) {});
}
} else if (res.cancel) {
console.log('取消');
}
}
});
} else {
uni.showModal({
title: '发现新版本',
confirmText: '立即更新',
cancelText: '下次更新',
content: res.message,
success: res => {
if (res.confirm) {
uni.showLoading('下载中...');
if (uni.getSystemInfoSync().platform ==
'android') {
uni.downloadFile({
url: downloadLink,
success: downloadResult => {
if (downloadResult
.statusCode ===
200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
entry.getParent(_oldFile=>{
entry.moveTo(_oldFile,'.apk',newFilePath=>{
console.log('newFilePath',newFilePath.fullPath)
plus.runtime
.install(newFilePath.fullPath, { force: false },
d => {
console
.log(
'install success...'
);
plus.runtime
.restart();
},
e => {
console.log(e)
console
.error(
'install fail...'
);
}
);
})
})
})
}
}
});
}
if (uni.getSystemInfoSync().platform ==
'ios') {
plus.runtime.openURL(downloadLink, function(
res) {});
}
} else if (res.cancel) {
console.log('取消');
}
}
});
}
}
}).catch((res)=>{
console.log(res)
})
});
// #endif
}); });
</script> </script>

View File

@@ -202,6 +202,7 @@ function request(args) {
method: method, method: method,
header: getHeader() header: getHeader()
}, extParams) }, extParams)
) )
}) })
} }

15
http/yskApi/version.js Normal file
View File

@@ -0,0 +1,15 @@
import http from './http.js'
const request=http.request
/**
* 查询所属渠道升级版本
* @returns
*/
export function getFindBySource(params) {
return request({
url: `/api/tbVersion/findBySource`,
method: 'get',
params
})
}

View File

@@ -541,7 +541,7 @@
</view> </view>
</uni-forms-item> </uni-forms-item>
</view> --> </view> -->
<!-- <view class="border-top-0"> <!-- <view class="border-top-0">
<view class="u-flex u-row-between u-p-b-24 u-p-t-20"> <view class="u-flex u-row-between u-p-b-24 u-p-t-20">
<view class="label-title">是否允许临时改价</view> <view class="label-title">是否允许临时改价</view>
<my-switch v-model="FormData.isTempPrice"></my-switch> <my-switch v-model="FormData.isTempPrice"></my-switch>
@@ -898,13 +898,13 @@
let proGroupVoGoodsIndex = undefined let proGroupVoGoodsIndex = undefined
function refChooseGuigeOpen(skuList, groupIndex, goodsIndex) { function refChooseGuigeOpen(skuList, groupIndex, goodsIndex) {
console.log(groupIndex, goodsIndex)
proGroupVoIndex = groupIndex proGroupVoIndex = groupIndex
proGroupVoGoodsIndex = goodsIndex proGroupVoGoodsIndex = goodsIndex
refChooseGuige.value.open(skuList) refChooseGuige.value.open(skuList)
} }
function refChooseGuigeConfirm(sku) { function refChooseGuigeConfirm(sku) {
console.log(sku);
FormData.proGroupVo[proGroupVoIndex].goods[proGroupVoGoodsIndex].skuName = sku.specSnap || sku.name FormData.proGroupVo[proGroupVoIndex].goods[proGroupVoGoodsIndex].skuName = sku.specSnap || sku.name
FormData.proGroupVo[proGroupVoIndex].goods[proGroupVoGoodsIndex].skuId = sku.id FormData.proGroupVo[proGroupVoIndex].goods[proGroupVoGoodsIndex].skuId = sku.id
proGroupVoIndex = undefined proGroupVoIndex = undefined
@@ -947,7 +947,6 @@
} }
function refChooseGoodsConfirm(arr) { function refChooseGoodsConfirm(arr) {
console.log(arr);
refChooseGoodsClose() refChooseGoodsClose()
arr = arr.map(v => { arr = arr.map(v => {
const { const {
@@ -976,10 +975,8 @@
skuName: '' skuName: ''
} }
}) })
console.log(arr);
console.log(FormData.groupType);
if (FormData.groupType == 0) { if (FormData.groupType == 0) {
console.log(FormData.proGroupVo[0]);
return FormData.proGroupVo[0].goods = arr return FormData.proGroupVo[0].goods = arr
} }
if (FormData.groupType == 1 && proGroupVoIndex !== undefined) { if (FormData.groupType == 1 && proGroupVoIndex !== undefined) {
@@ -1753,6 +1750,19 @@
}) })
}) })
} }
// 如果套餐没选择规格,默认选中第一条
console.log(submitData.proGroupVo)
if (submitData.proGroupVo) {
submitData.proGroupVo.forEach((res, index) => {
submitData.proGroupVo[index].goods.forEach(ele => {
if (!ele.skuId) {
ele.skuId = ele.skuList[0].id
ele.skuName = ele.skuList[0].specSnap || ele.skuList[0].name
}
})
})
}
submitData.selectSpec = submitData.selectSpec =
$addProduct(submitData).then(res => { $addProduct(submitData).then(res => {
infoBox.showSuccessToast('添加成功') infoBox.showSuccessToast('添加成功')

Binary file not shown.