优化部分代码样式以及bug,新增app升级功能

master
lemon橪 2021-05-21 16:47:26 +08:00
parent 8fe64bd3c6
commit 533375f056
16 changed files with 127 additions and 138 deletions

View File

@ -21,6 +21,7 @@ export default {
onLaunch: function () { onLaunch: function () {
// #ifdef APP-PLUS // #ifdef APP-PLUS
this.checkArguments(); // this.checkArguments(); //
APPUpdate();
// //
plus.globalEvent.addEventListener("newintent", (e) => { plus.globalEvent.addEventListener("newintent", (e) => {
this.checkArguments(); // this.checkArguments(); //

View File

@ -30,13 +30,25 @@ export function getGoodsRelated(params) {
* @param skuId 商品ID * @param skuId 商品ID
* @returns {AxiosPromise} * @returns {AxiosPromise}
*/ */
export function getGoods(skuId, goodsId, distributionId) { export function getGoods(skuId, goodsId) {
return http.request({ return http.request({
url: `/goods/sku/${goodsId}/${skuId}${distributionId ? '?distributionId='+distributionId : ''}`, url: `/goods/sku/${goodsId}/${skuId}`,
method: Method.GET, method: Method.GET,
}); });
} }
/**
* 获取商品分销
* @param distributionId 商品分销ID
*/
export function getGoodsDistribution(distributionId) {
return http.request({
url: `/distribution/bindingDistribution/${distributionId}`,
method: Method.GET,
});
}
/** /**
* 获取商品列表 * 获取商品列表
* @param params * @param params

View File

@ -146,7 +146,7 @@ export function AppendCommentsOrder(params) {
}); });
} }
// TODO 第一版本暂未实现此功能
/** /**
* 商品咨询 * 商品咨询
* @param goods_id * @param goods_id

View File

@ -5,6 +5,7 @@
import {http,Method} from '@/utils/request.js'; import {http,Method} from '@/utils/request.js';
const request = http.request const request = http.request
import api from '@/config/api.js';
/** /**
* 获取微信消息订阅 * 获取微信消息订阅
@ -67,16 +68,14 @@ export function getLogisticsMessages(params) {
/** /**
* TODO 获取版本更新信息 暂无此功能后续会优化更新 * TODO 获取版本更新信息 暂无此功能后续会优化更新
* @param params * @param appType
* @returns {AxiosPromise} * @returns {AxiosPromise}
* *
*/ */
export function getAppVersionList(params) { export function getAppVersionList(appType) {
params = params || {};
params.pageSize = params.pageSize || 5;
return http.request({ return http.request({
url: 'members/app/version', url: `/appVersion/${appType}`,
method: Method.GET, method: Method.GET,
params, type:"manager"
}); });
} }

View File

@ -11,10 +11,11 @@ const dev = {
const prod = { const prod = {
common: "https://common-api.pickmall.cn", common: "https://common-api.pickmall.cn",
buyer: "https://buyer-api.pickmall.cn", buyer: "https://buyer-api.pickmall.cn",
}; };
//默认生产环境 //默认生产环境
let api = prod; let api = dev;
//如果是开发环境 //如果是开发环境
if (process.env.NODE_ENV == "development") { if (process.env.NODE_ENV == "development") {
api = dev; api = dev;

View File

@ -3,7 +3,7 @@
"appid" : "__UNI__C100675", "appid" : "__UNI__C100675",
"description" : "", "description" : "",
"versionName" : "4.0.14", "versionName" : "4.0.14",
"versionCode" : 4000013, "versionCode" : 4000014,
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
"compatible" : { "compatible" : {

View File

@ -16,9 +16,9 @@
{{ comment.content }} {{ comment.content }}
</view> </view>
<!-- 如果有图片则会循环显示评价的图片 --> <!-- 如果有图片则会循环显示评价的图片 -->
<view class="goods-imgs-view" v-if="comment.image != null && comment.image.length != 0"> <view class="goods-imgs-view" v-if="comment.images != null && comment.images.length != 0">
<view class="img-view" v-for="(img, imgIndex) in comment.image.split(',')" :key="imgIndex"> <view class="img-view" v-for="(img, imgIndex) in comment.images.split(',')" :key="imgIndex">
<u-image @click.native="preview(comment.image.split(','),imgIndex)" width="160rpx" height="160rpx" :src="img"></u-image> <u-image @click.native="preview(comment.images.split(','),imgIndex)" width="160rpx" height="160rpx" :src="img"></u-image>
</view> </view>
</view> </view>
<view class="goods-name"> <view class="goods-name">

View File

@ -117,7 +117,6 @@ export default {
this.form.skuId = this.order.orderItems[0].skuId; this.form.skuId = this.order.orderItems[0].skuId;
}, },
methods: { methods: {
/** /**
* 点击评价 * 点击评价
*/ */
@ -134,7 +133,7 @@ export default {
}); });
commentsMemberOrder(this.form).then((res) => { commentsMemberOrder(this.form).then((res) => {
uni.hideLoading(); uni.hideLoading();
if (res.data.success) {
uni.showToast({ uni.showToast({
title: "发布评价成功", title: "发布评价成功",
duration: 2000, duration: 2000,
@ -142,9 +141,10 @@ export default {
success: () => { success: () => {
setTimeout(() => { setTimeout(() => {
uni.navigateBack(); uni.navigateBack();
}, 1000); }, 2000);
}, },
}); });
}
}); });
}, },

View File

@ -54,7 +54,7 @@
<u-button ripple shape="circle" class="rebuy-btn" size="mini" v-if="order.allowOperationVO.showLogistics" @click="navigateToLogistics(order)"> <u-button ripple shape="circle" class="rebuy-btn" size="mini" v-if="order.allowOperationVO.showLogistics" @click="navigateToLogistics(order)">
查看物流 查看物流
</u-button> </u-button>
<u-button ripple :customStyle="{'background':$lightColor,'color':'#fff' }" shape="circle" class="pay-btn" size="mini" v-if="order.allowOperationVO.rog" @click="onRog(order.sn)"> <u-button ripple :customStyle="{'background':lightColor,'color':'#fff' }" shape="circle" class="pay-btn" size="mini" v-if="order.allowOperationVO.rog" @click="onRog(order.sn)">
确认收货 确认收货
</u-button> </u-button>
<u-button ripple shape="circle" class="rebuy-btn" size="mini" v-if=" <u-button ripple shape="circle" class="rebuy-btn" size="mini" v-if="
@ -83,7 +83,7 @@
<u-radio-group v-model="reason"> <u-radio-group v-model="reason">
<view class="value"> <view class="value">
<view class="radio-view" :key="index" v-for="(item, index) in cancelList"> <view class="radio-view" :key="index" v-for="(item, index) in cancelList">
<u-radio :active-color="$lightColor" label-size="25" shape="circle" :name="item.reason" @change="reasonChange">{{ item.reason }}</u-radio> <u-radio :active-color="lightColor" label-size="25" shape="circle" :name="item.reason" @change="reasonChange">{{ item.reason }}</u-radio>
</view> </view>
</view> </view>
</u-radio-group> </u-radio-group>
@ -94,7 +94,7 @@
</view> </view>
</u-popup> </u-popup>
<u-toast ref="uToast" /> <u-toast ref="uToast" />
<u-modal v-model="rogShow" :show-cancel-button="true" :content="'是否确认收货?'" @confirm="confirmRog"></u-modal> <u-modal :confirm-color="lightColor" v-model="rogShow" :show-cancel-button="true" :content="'是否确认收货?'" @confirm="confirmRog"></u-modal>
</view> </view>
</template> </template>
@ -111,6 +111,7 @@ export default {
}, },
data() { data() {
return { return {
lightColor:this.$lightColor,
tabCurrentIndex: 0, // tabCurrentIndex: 0, //
navList: [ navList: [
//list //list
@ -492,7 +493,7 @@ page,
} }
.swiper-box { .swiper-box {
height: calc(100% - 40px); height: calc(100vh - 40px);
} }
.list-scroll-content { .list-scroll-content {

View File

@ -37,7 +37,7 @@
<div class="content">{{ item.content }}</div> <div class="content">{{ item.content }}</div>
<view class="img"> <view class="img">
<!-- 循环出用户评价的图片 --> <!-- 循环出用户评价的图片 -->
<u-image width="140rpx" height="140rpx" v-if="item.image" v-for="(img, i) in splitImg(item.image)" :src="img" :key="i" @click="preview(splitImg(item.image), i)"> <u-image width="140rpx" height="140rpx" v-if="item.images" v-for="(img, i) in splitImg(item.images)" :src="img" :key="i" @click="preview(splitImg(item.images), i)">
</u-image> </u-image>
</view> </view>
<view class="bot"> <view class="bot">

View File

@ -223,7 +223,12 @@
<script> <script>
/************接口API***************/ /************接口API***************/
import { getGoods, getGoodsList, getMpScene } from "@/api/goods.js"; import {
getGoods,
getGoodsList,
getMpScene,
getGoodsDistribution,
} from "@/api/goods.js";
import * as API_trade from "@/api/trade.js"; import * as API_trade from "@/api/trade.js";
import * as API_Members from "@/api/members.js"; import * as API_Members from "@/api/members.js";
import * as API_store from "@/api/store.js"; import * as API_store from "@/api/store.js";
@ -393,7 +398,8 @@ export default {
}, },
async onLoad(options) { async onLoad(options) {
this.routerVal = options; this.routerVal = options;
},
async onShow() {
this.goodsDetail = {}; this.goodsDetail = {};
//ids //ids
if (this.routerVal.scene) { if (this.routerVal.scene) {
@ -407,11 +413,11 @@ export default {
this.init( this.init(
this.routerVal.id, this.routerVal.id,
this.routerVal.goodsId, this.routerVal.goodsId,
this.routerVal.distributionId this.routerVal.distributionId,
this.routerVal.whetherPoint
); );
} }
}, },
onShow() {},
methods: { methods: {
// //
emptyPromotion() { emptyPromotion() {
@ -432,8 +438,16 @@ export default {
title: "加载中", title: "加载中",
mask: true, mask: true,
}); });
let response = await getGoods(id, goodsId, distributionId);
let response = await getGoods(id, goodsId);
//
if (distributionId || this.$store.state.distributionId) {
let disResult = await getGoodsDistribution(distributionId);
if (!disResult.data.success || disResult.statusCode == 403) {
this.$store.state.distributionId = distributionId;
}
}
uni.hideLoading(); uni.hideLoading();
/**商品信息以及规格信息存储 */ /**商品信息以及规格信息存储 */
this.goodsDetail = response.data.result.data; this.goodsDetail = response.data.result.data;
@ -539,16 +553,13 @@ export default {
* 返回 * 返回
*/ */
back() { back() {
if (getCurrentPages().length == 1) {
if(getCurrentPages().length ==1){
uni.switchTab({ uni.switchTab({
url: '/pages/tabbar/home/index' url: "/pages/tabbar/home/index",
}); });
} } else {
else{
uni.navigateBack(); uni.navigateBack();
} }
}, },
/** /**

View File

@ -17,11 +17,11 @@
<view class="store-line"> <view class="store-line">
<u-checkbox-group class="store-line-check"> <u-checkbox-group class="store-line-check">
<!-- #ifndef MP-WEIXIN --> <!-- #ifndef MP-WEIXIN -->
<u-checkbox shape="circle" :active-color="$lightColor" v-model="item.checked" @change="checkboxChangeDP(item)"></u-checkbox> <u-checkbox shape="circle" :active-color="lightColor" v-model="item.checked" @change="checkboxChangeDP(item)"></u-checkbox>
<!-- #endif --> <!-- #endif -->
<!-- 微信小程序这里 v-model出现问题改用:value --> <!-- 微信小程序这里 v-model出现问题改用:value -->
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<u-checkbox shape="circle" :active-color="$lightColor" :value="item.checked" @change="checkboxChangeDP(item)"></u-checkbox> <u-checkbox shape="circle" :active-color="lightColor" :value="item.checked" @change="checkboxChangeDP(item)"></u-checkbox>
<!-- #endif --> <!-- #endif -->
</u-checkbox-group> </u-checkbox-group>
<span class="storeName store-line-desc" @click.stop="navigateToStore(item)">{{ <span class="storeName store-line-desc" @click.stop="navigateToStore(item)">{{
@ -49,11 +49,11 @@
<view> <view>
<u-checkbox-group v-if="skuItem.invalid == 0"> <u-checkbox-group v-if="skuItem.invalid == 0">
<!-- #ifndef MP-WEIXIN --> <!-- #ifndef MP-WEIXIN -->
<u-checkbox shape="circle" :active-color="$lightColor" class="c-left" v-model="skuItem.checked" @change="checkboxChange(skuItem)"></u-checkbox> <u-checkbox shape="circle" :active-color="lightColor" class="c-left" v-model="skuItem.checked" @change="checkboxChange(skuItem)"></u-checkbox>
<!-- #endif --> <!-- #endif -->
<!-- 微信小程序这里 v-model出现问题改用:value --> <!-- 微信小程序这里 v-model出现问题改用:value -->
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<u-checkbox shape="circle" :active-color="$lightColor" class="c-left" :value="skuItem.checked" @change="checkboxChange(skuItem)"></u-checkbox> <u-checkbox shape="circle" :active-color="lightColor" class="c-left" :value="skuItem.checked" @change="checkboxChange(skuItem)"></u-checkbox>
<!-- #endif --> <!-- #endif -->
</u-checkbox-group> </u-checkbox-group>
<span class="invalid" v-else style="font-size: 24rpx">失效</span> <span class="invalid" v-else style="font-size: 24rpx">失效</span>
@ -110,7 +110,7 @@
<!-- 结账 --> <!-- 结账 -->
<div class="box box6"> <div class="box box6">
<view class="navL"> <view class="navL">
<u-checkbox shape="circle" :active-color="$lightColor" v-model="checkout" @change="checkOut()" label-size="24"></u-checkbox> <u-checkbox shape="circle" :active-color="lightColor" v-model="checkout" @change="checkOut()" label-size="24"></u-checkbox>
<span class="price"> <span class="price">
<div class="prices"> <div class="prices">
<div class="fullPrice"> <div class="fullPrice">

View File

@ -10,9 +10,9 @@ import {
const platform = uni.getSystemInfoSync().platform; const platform = uni.getSystemInfoSync().platform;
// 主颜色 // 主颜色
const $mainColor = "#ff6b35"; const $mainColor = "#1ABC9C";
// 弹窗图标url // 弹窗图标url
const $iconUrl = "https://lilistore-oss.oss-cn-beijing.aliyuncs.com/app/upgrade.png"; const $iconUrl = "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/app/upgrade.png";
// 获取当前应用的版本号 // 获取当前应用的版本号
export const getCurrentNo = function (callback) { export const getCurrentNo = function (callback) {
@ -25,72 +25,27 @@ export const getCurrentNo = function (callback) {
}); });
} }
// 发起ajax请求获取服务端版本号 // 发起ajax请求获取服务端版本号
export const getServerNo = function (version, isPrompt = false, callback) { export const getServerNo = function (callback) {
let httpData = { let type;
version: version
}; platform == "android" ? type = "ANDROID" : type = "IOS"
let params = {
pageNumber: 1, getAppVersionList(type).then(res => {
pageSize: 5
}; if(res.data.success && res.data.result.downloadUrl){
if (platform == "android") { let response = res.data.result
httpData.type = 1101; let result ={}
params.type = 0;
} else {
httpData.type = 1102;
params.type = 1;
}
/*
* version: 应用当前版本号已自动获取
* type平台1101是安卓1102是IOS
*/
/****************以下是示例*******************/
getAppVersionList(params).then(res => {
if (res.statusCode === 200) {
const response = res.data.data.find(ele => {
let versionDetail = ele.version.replace(/\./g, "");
if (versionDetail.length < version.length) {
versionDetail = versionDetail.padEnd(version.length, "0");
}
if (versionDetail > version) {
return ele;
}
});
if (response && response.download_url) {
let result = {};
result.versionCode = response.version; result.versionCode = response.version;
result.versionName = response.version_name; result.versionName = response.versionName;
result.versionInfo = response.content; result.versionInfo = response.content || '暂无';
result.forceUpdate = response.force_update; result.forceUpdate = response.forceUpdate;
result.downloadUrl = response.download_url; result.downloadUrl = response.downloadUrl;
console.log(result,response)
callback && callback(result); callback && callback(result);
} }
}
}) })
// 可以用自己项目的请求方法
// http.get("api/common/v1/app_version", httpData,{
// isPrompt: isPrompt
// }).then(res => {
// /* res的数据说明
// * | 参数名称 | 一定返回 | 类型 | 描述
// * | -------------|--------- | --------- | ------------- |
// * | versionCode | y | int | 版本号 |
// * | versionName | y | String | 版本名称 |
// * | versionInfo | y | String | 版本信息 |
// * | forceUpdate | y | boolean | 是否强制更新 |
// * | downloadUrl | y | String | 版本下载链接IOS安装包更新请放跳转store应用商店链接,安卓apk和wgt文件放文件下载链接 |
// */
// if (res && res.downloadUrl) {
// callback && callback(res);
// } else if (isPrompt) {
// uni.showToast({
// title: "暂无新版本",
// icon: "none"
// });
// }
// });
/****************以上是示例*******************/
} }
// 从服务器下载应用资源包wgt文件 // 从服务器下载应用资源包wgt文件
export const getDownload = function (data) { export const getDownload = function (data) {
@ -180,12 +135,16 @@ export const getDownload = function (data) {
function drawtext(text, maxWidth) { function drawtext(text, maxWidth) {
let textArr = text.split(""); let textArr = text.split("");
let len = textArr.length; let len = textArr.length;
// 上个节点 // 上个节点
let previousNode = 0; let previousNode = 0;
// 记录节点宽度 // 记录节点宽度
let nodeWidth = 0; let nodeWidth = 0;
// 文本换行数组 // 文本换行数组
let rowText = []; let rowText = [];
// 如果是字母,侧保存长度 // 如果是字母,侧保存长度
let letterWidth = 0; let letterWidth = 0;
// 汉字宽度 // 汉字宽度
@ -267,6 +226,7 @@ function drawtext(text, maxWidth) {
content: text.substring(previousNode, len) content: text.substring(previousNode, len)
}); });
} }
return rowText; return rowText;
} }
// 是否更新弹窗 // 是否更新弹窗
@ -291,6 +251,7 @@ function updatePopup(data, callback) {
const viewContentWidth = parseInt(popupViewWidth - (viewContentPadding * 5)); const viewContentWidth = parseInt(popupViewWidth - (viewContentPadding * 5));
// 描述的列表 // 描述的列表
const descriptionList = drawtext(data.versionInfo, viewContentWidth); const descriptionList = drawtext(data.versionInfo, viewContentWidth);
// 弹窗容器高度 // 弹窗容器高度
let popupViewHeight = 400; let popupViewHeight = 400;
let popupViewContentList = [{ let popupViewContentList = [{
@ -337,7 +298,6 @@ function updatePopup(data, callback) {
text: '新版本特性:', text: '新版本特性:',
textStyles: { textStyles: {
size: '20px', size: '20px',
color: "#1ABC9C",
lineSpacing: "50%", lineSpacing: "50%",
align: "left" align: "left"
}, },
@ -841,7 +801,7 @@ function downloadPopup(data, callback, cancelCallback, rebootCallback) {
} }
export default function (isPrompt = false) { export default function (isPrompt = false) {
getCurrentNo(version => { getCurrentNo(version => {
getServerNo(version.versionCode, isPrompt, res => { getServerNo( res => {
if (res.forceUpdate) { if (res.forceUpdate) {
if (/\.wgt$/i.test(res.downloadUrl)) { if (/\.wgt$/i.test(res.downloadUrl)) {
getDownload(res); getDownload(res);

View File

@ -10,7 +10,10 @@ const store = new Vuex.Store({
/** /**
* 是否需要强制登录 * 是否需要强制登录
*/ */
forcedLogin: false, forcedLogin: false,
distributionId:"", //分销员Id 如果当前账户从未登录过时记录
hasLogin: storage.getHasLogin(), hasLogin: storage.getHasLogin(),
userInfo: storage.getUserInfo(), userInfo: storage.getUserInfo(),
uuid: storage.getUuid(), uuid: storage.getUuid(),

View File

@ -120,6 +120,7 @@ http.interceptors.request.use(
}; };
let params = config.params || {}; let params = config.params || {};
params = { ...params, ..._params }; params = { ...params, ..._params };
config.params = params; config.params = params;
config.header.accessToken = accessToken; config.header.accessToken = accessToken;
} }
@ -184,7 +185,7 @@ http.interceptors.response.use(
return response; return response;
}, },
(error) => { (error) => {
return response; return error;
} }
); );

View File

@ -1,20 +1,20 @@
module.exports = { // module.exports = {
/** // /**
* 此处为发行h5,微信小程序app中删除console // * 此处为发行h5,微信小程序app中删除console
* 如需显示console 需要注释此处重新运行 // * 如需显示console 需要注释此处重新运行
*/ // */
chainWebpack: (config) => { // chainWebpack: (config) => {
// 发行或运行时启用了压缩时会生效 // // 发行或运行时启用了压缩时会生效
config.optimization.minimizer('terser').tap((args) => { // config.optimization.minimizer('terser').tap((args) => {
const compress = args[0].terserOptions.compress // const compress = args[0].terserOptions.compress
// 非 App 平台移除 console 代码(包含所有 console 方法,如 log,debug,info...) // // 非 App 平台移除 console 代码(包含所有 console 方法,如 log,debug,info...)
compress.drop_console = true // compress.drop_console = true
compress.pure_funcs = [ // compress.pure_funcs = [
'__f__', // App 平台 vue 移除日志代码 // '__f__', // App 平台 vue 移除日志代码
// 'console.debug' // 可移除指定的 console 方法 // // 'console.debug' // 可移除指定的 console 方法
] // ]
return args // return args
}) // })
} // }
} // }