代码优化

This commit is contained in:
905166056 2021-04-12 09:12:19 +08:00
parent c2620672bb
commit 2b3ee8f6d3
8 changed files with 89 additions and 42 deletions

View File

@ -59,12 +59,12 @@ export function getWAppId(){
* 页面加载方法
* @param {Object} _option 页面参数对象
*/
export function onLoad(_option){
export function onLoad(_option, callback = () => {}){
// #ifdef H5
let _key = _option.key;
if (isNotNull(_key)) {
//根据key 去做登录
doLoginOwnerByKey(_key);
doLoginOwnerByKey(_key, callback);
}
// #endif
//初始化wAppId

View File

@ -11,7 +11,7 @@ import {getWAppId} from '../api/init/initApi.js'
* @param {Object} _key 自登陆key
* add by wuxw QQ 928255095
*/
export function doLoginOwnerByKey(_key) {
export function doLoginOwnerByKey(_key, callback = () => {}) {
requestNoAuth({
url: url.loginOwnerByKey,
method: 'post',
@ -51,6 +51,7 @@ export function doLoginOwnerByKey(_key) {
wx.setStorageSync(mapping.TOKEN, _param.token);
//保存临时 钥匙
wx.setStorageSync(mapping.OWNER_KEY, _param.key);
callback();
},
fail: function(error) {
// 调用服务端登录接口失败

View File

@ -43,7 +43,7 @@ import {
* 跳转功能封装
* @param {Object} _param 跳转入参
*/
export function navigateTo(_param) {
export function navigateTo(_param, callback = () => {}) {
//参数中刷入wAppId
let _url = _param.url;
@ -87,7 +87,7 @@ export function navigateTo(_param) {
//小程序登录
// #ifdef MP-WEIXIN
doLogin();
doLogin(callback);
// #endif
// #ifdef APP-PLUS

View File

@ -1,15 +1,27 @@
<template>
<view>
<view class="content bg-white margin-top">
<view class="flex solid-bottom padding justify-start">
<view class=" padding-sm radius">服务评分</view>
<view class=" padding-sm radius">
<sx-rate :value="4" :fontSize="fontSize" :value.sync="rateSync" @change="onChange" />
<view class="flex solid-bottom justify-start">
<view class="item-title padding-sm radius">综合评分</view>
<view class="item-star padding-sm radius">
<sx-rate :value="4" :fontSize="fontSize" :value.sync="rateSync1" @change="appraiseScoreChange" />
</view>
</view>
<view class="flex solid-bottom justify-start">
<view class="item-title padding-sm radius">维修速度</view>
<view class="item-star padding-sm radius">
<sx-rate :value="4" :fontSize="fontSize" :value.sync="rateSync2" @change="doorSpeedScoreChange" />
</view>
</view>
<view class="flex solid-bottom justify-start">
<view class="item-title padding-sm radius">维修员服务</view>
<view class="item-star padding-sm radius">
<sx-rate :value="4" :fontSize="fontSize" :value.sync="rateSync3" @change="repairmanServiceScoreChange" />
</view>
</view>
<view class="cu-form-group padding align-start">
<view class="title padding-left-sm">服务评价</view>
<textarea maxlength="200" v-model="context" placeholder="请填写本地服务评价"></textarea>
<textarea maxlength="200" v-model="context" placeholder="请您填写本次服务感受和评价,以便给大家提供更好的服务品质哦!"></textarea>
</view>
<view class="flex flex-direction margin">
@ -30,9 +42,13 @@
data() {
return {
fontSize:'60upx',
rateSync: 2,
rateSync1: 2,
rateSync2: 2,
rateSync3: 2,
animation: true,
curAppraise: 4,
curAppraise: 2,
curDoorSpeed: 2,
curRepairmanService: 2,
context: '',
repairId:'',
userId:'',
@ -53,9 +69,15 @@
});
},
methods: {
onChange(e) {
appraiseScoreChange(e) {
this.curAppraise = e;
},
doorSpeedScoreChange(e) {
this.curDoorSpeed = e;
},
repairmanServiceScoreChange(e) {
this.curRepairmanService = e;
},
submitAppraiseRepair:function(){
if(this.context == ''){
uni.showToast({
@ -74,6 +96,8 @@
let _data = {
"appraiseScore":this.curAppraise,
"doorSpeedScore":this.curDoorSpeed,
"repairmanServiceScore":this.curRepairmanService,
"appraiseType":"10001",
"context":this.context,
"appraiseUserId":this.userId,
@ -93,7 +117,6 @@
uni.navigateBack({
delta: 1
});
})
.then((error)=>{
wx.showToast({
@ -101,7 +124,7 @@
icon: 'none',
duration: 2000
});
});
});
}
}
}
@ -111,4 +134,11 @@
.content {
height: 100%;
}
.item-title{
width: 200rpx;
}
.item-star, .item-title{
vertical-align: middle;
line-height: 100rpx;
}
</style>

View File

@ -111,7 +111,9 @@
components: {},
props: {},
onLoad: function(options) {
context.onLoad(options);
context.onLoad(options, () => {
this.refreshPageLoginInfo();
});
let _that = this;
let login = context.checkLoginStatus();
if (login) {
@ -122,27 +124,28 @@
}
},
onShow: function() {
let _that = this; //
if (!_that.ckeckUserInfo()) {
_that.login = false;
return;
}
_that.login = true;
_that.loadOwenrInfo();
_that.userInfo = context.getUserInfo();
this.loadOwnerHeaderImg();
// _that.setData({
// userInfo: context.getUserInfo()
// });
this.refreshPageLoginInfo();
},
methods: {
// onShow
//
refreshPageLoginInfo: function(){
let _that = this; //
if (!_that.ckeckUserInfo()) {
_that.login = false;
return;
}
_that.login = true;
_that.loadOwenrInfo();
_that.userInfo = context.getUserInfo();
this.loadOwnerHeaderImg();
},
bindingOwner: function() {
if (!this.ckeckUserInfo()) {
this.vc.navigateTo({
url: '../showlogin/showlogin'
}, () => {
this.refreshPageLoginInfo();
});
return;
}
@ -154,6 +157,8 @@
if (!this.ckeckUserInfo()) {
this.vc.navigateTo({
url: '../showlogin/showlogin'
}, () => {
this.refreshPageLoginInfo();
});
return;
}
@ -184,6 +189,8 @@
if (!this.ckeckUserInfo()) {
this.vc.navigateTo({
url: '../showlogin/showlogin'
}, () => {
this.refreshPageLoginInfo();
});
return;
}
@ -196,6 +203,8 @@
if (!this.ckeckUserInfo()) {
this.vc.navigateTo({
url: '../showlogin/showlogin'
}, () => {
this.refreshPageLoginInfo();
});
return;
}
@ -212,6 +221,8 @@
if (!this.ckeckUserInfo()) {
this.vc.navigateTo({
url: '../showlogin/showlogin'
}, () => {
this.refreshPageLoginInfo();
});
return;
}
@ -224,6 +235,8 @@
if (!this.ckeckUserInfo()) {
this.vc.navigateTo({
url: '../showlogin/showlogin'
}, () => {
this.refreshPageLoginInfo();
});
return;
}
@ -235,6 +248,8 @@
if (!this.ckeckUserInfo()) {
this.vc.navigateTo({
url: '../showlogin/showlogin'
}, () => {
this.refreshPageLoginInfo();
});
return;
}
@ -246,6 +261,8 @@
if (!this.ckeckUserInfo()) {
this.vc.navigateTo({
url: '../showlogin/showlogin'
}, () => {
this.refreshPageLoginInfo();
});
return;
}

View File

@ -22,7 +22,7 @@
<view v-if="imgRecordList.length > 0">
<view class="block__title">图片</view>
<view class="record-img-item" v-for="(item,index) in imgRecordList" :key="index">
<image :src="commonBaseUrl + item.url" :data-url="commonBaseUrl + item.url" @tap="preview" mode="widthFix"></image>
<image :src="commonBaseUrl + item.url" :data-url="commonBaseUrl + item.url" :data-index="index" @tap="preview" mode="widthFix"></image>
</view>
</view>
<view v-if="videoRecordList.length > 0">
@ -32,13 +32,11 @@
</view>
</view>
</view>
<viewImage ref="viewImageRef"></viewImage>
</view>
</template>
<script>
import {queryRoomRenovationRecordDetail} from '../../api/roomRenovation/roomRenovationApi.js'
import viewImage from '@/components/view-image/view-image.vue'
import conf from '../../conf/config.js'
export default {
data() {
@ -52,7 +50,6 @@
},
components: {
viewImage
},
props: {},
@ -103,8 +100,15 @@
})
},
preview: function(e) {
let _url = e.target.dataset.url;
this.$refs.viewImageRef.showThis(_url);
let index = e.target.dataset.index;
let urls = [];
this.imgRecordList.forEach((item) => {
urls.push(this.commonBaseUrl + item.url);
})
uni.previewImage({
current: index,
urls: urls
})
}
}
};

View File

@ -120,7 +120,6 @@
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log('options', options);
context.onLoad(options);
// #ifdef MP-WEIXIN
let accountInfo = uni.getAccountInfoSync();

View File

@ -170,7 +170,6 @@
this.appId = uni.getStorageSync(constant.mapping.W_APP_ID)
// #endif
let _fee = JSON.parse(options.fee);
console.log('_fee', _fee);
let _amount = _fee.amount;
let _receivableAmount = _amount;
if(_fee.feeFlag == "2006012"){ //
@ -218,7 +217,6 @@
this.receivableAmount = (parseFloat(this.receivableAmount) + parseFloat(_price)).toFixed(2);
},
dateChange: function(e) {
console.log("onConfirm", e);
let _feeMonthName = null;
_feeMonthName = this.feeMonthList[e.detail.value];;
let _feeMonth = _feeMonthName.replace("个月","");
@ -263,8 +261,6 @@
data: _objData,
//
success: function(res) {
console.log(res);
if (res.statusCode == 200 && res.data.code == '0') {
let data = res.data; //