Browse Source

解决sonar扫描的异味

devlop
邓雄飞 4 years ago
parent
commit
26763f2e54
17 changed files with 920 additions and 1024 deletions
  1. 4
      App.vue
  2. 1753
      components/qn-datetime-picker/calendar.vue
  3. 13
      components/qn-datetime-picker/keypress.js
  4. 35
      components/qn-datetime-picker/qn-datetime-picker.vue
  5. 3
      components/qn-datetime-picker/time-picker.vue
  6. 14
      components/qn-datetime-picker/util.js
  7. 1
      components/qn-input-number/qn-input-number.vue
  8. 7
      main.js
  9. 15
      pages/add-account/index.vue
  10. 5
      pages/add-address-manage/index.vue
  11. 4
      pages/address-manage/index.vue
  12. 37
      pages/cart/index.vue
  13. 2
      pages/cart/no-data.vue
  14. 27
      pages/for-comparison/index.vue
  15. 12
      store/index.js
  16. 6
      utils/hook.js
  17. 6
      utils/index.js

4
App.vue

@ -21,9 +21,7 @@ export default {
go2('error')
}
}
},
onShow: function () {},
onHide: function () {}
}
}
</script>

1753
components/qn-datetime-picker/calendar.vue
File diff suppressed because it is too large
View File

13
components/qn-datetime-picker/keypress.js

@ -7,7 +7,7 @@ export default {
default: false
}
},
mounted () {
mounted() {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
@ -23,10 +23,10 @@ export default {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const keyName = Object.keys(keyNames).find((key) => {
const name = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
return value === name || (Array.isArray(value) && value.includes(name))
})
if (keyName) {
// 避免和其他按键事件冲突
@ -39,7 +39,6 @@ export default {
this.$once('hook:beforeDestroy', () => {
document.removeEventListener('keyup', listener)
})
},
render: () => {}
}
}
// #endif
// #endif

35
components/qn-datetime-picker/qn-datetime-picker.vue

@ -21,9 +21,6 @@
<uni-icons type="clear" color="#e1e1e1" size="15"></uni-icons>
</view>
</view>
<!-- <view v-if="showClearIcon" class="uni-date__icon-clear" @click.stop="clear">
<uni-icons type="clear" color="#e1e1e1" size="15"></uni-icons>
</view> -->
</view>
</slot>
</view>
@ -57,7 +54,6 @@
style="padding: 0 8px"
/>
<view v-if="hasTime" class="popup-x-footer">
<!-- <text class="">此刻</text> -->
<text class="confirm" @click="confirmSingleChange">{{ okText }}</text>
</view>
<view class="uni-date-popper__arrow"></view>
@ -294,7 +290,7 @@ export default {
watch: {
type: {
immediate: true,
handler(newVal, oldVal) {
handler(newVal) {
if (newVal.indexOf('time') !== -1) {
this.hasTime = true
} else {
@ -309,7 +305,7 @@ export default {
},
value: {
immediate: true,
handler(newVal, oldVal) {
handler(newVal) {
if (this.isEmitValue) {
this.isEmitValue = false
return
@ -320,7 +316,7 @@ export default {
start: {
immediate: true,
handler(newVal, oldVal) {
handler(newVal) {
if (!newVal) return
const { defDate, defTime } = this.parseDate(newVal)
this.caleRange.startDate = defDate
@ -332,7 +328,7 @@ export default {
end: {
immediate: true,
handler(newVal, oldVal) {
handler(newVal) {
if (!newVal) return
const { defDate, defTime } = this.parseDate(newVal)
this.caleRange.endDate = defDate
@ -345,13 +341,11 @@ export default {
computed: {
reactStartTime() {
const activeDate = this.isRange ? this.tempRange.startDate : this.tempSingleDate
const res = activeDate === this.caleRange.startDate ? this.caleRange.startTime : ''
return res
return activeDate === this.caleRange.startDate ? this.caleRange.startTime : ''
},
reactEndTime() {
const activeDate = this.isRange ? this.tempRange.endDate : this.tempSingleDate
const res = activeDate === this.caleRange.endDate ? this.caleRange.endTime : ''
return res
return activeDate === this.caleRange.endDate ? this.caleRange.endTime : ''
},
reactMobDefTime() {
const times = {
@ -367,7 +361,6 @@ export default {
}
},
datePopupWidth() {
// todo
return this.isRange ? 653 : 301
},
@ -409,20 +402,12 @@ export default {
},
showClearIcon() {
const { clearIcon, disabled, singleVal, range } = this
const bool = clearIcon && !disabled && (singleVal || (range.startDate && range.endDate))
return bool
return clearIcon && !disabled && (singleVal || (range.startDate && range.endDate))
}
},
created() {
this.form = this.getForm('uniForms')
this.formItem = this.getForm('uniFormsItem')
// if (this.formItem) {
// if (this.formItem.name) {
// this.rename = this.formItem.name
// this.form.inputChildrens.push(this)
// }
// }
},
mounted() {
this.platform()
@ -688,11 +673,7 @@ export default {
startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
//
endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
if (startDate <= endDate) {
return true
} else {
return false
}
return startDate <= endDate
},
/**

3
components/qn-datetime-picker/time-picker.vue

@ -79,9 +79,6 @@
</view>
</view>
</view>
<!-- #ifdef H5 -->
<!-- <keypress v-if="visible" @esc="tiggerTimePicker" @enter="setTime" /> -->
<!-- #endif -->
</view>
</template>

14
components/qn-datetime-picker/util.js

@ -8,7 +8,7 @@ class Calendar {
// multipleStatus
} = {}) {
// 当前日期
this.date = this.getDate(new Date()) // 当前初入日期
this.date = this.getDate(new Date())
// 打点信息
this.selected = selected || []
// 范围开始
@ -20,8 +20,6 @@ class Calendar {
this.cleanMultipleStatus()
// 每周日期
this.weeks = {}
// this._getWeek(this.date.fullDate)
// this.multipleStatus = multipleStatus
this.lastHover = false
}
/**
@ -355,7 +353,7 @@ class Calendar {
* @param {Object} dateData
*/
_getWeek(dateData) {
const { fullDate, year, month, date, day } = this.getDate(dateData)
const { year, month } = this.getDate(dateData)
let firstDay = new Date(year, month - 1, 1).getDay()
let currentDay = new Date(year, month, 0).getDate()
let dates = {
@ -379,14 +377,6 @@ class Calendar {
this.canlender = canlender
this.weeks = weeks
}
//静态方法
// static init(date) {
// if (!this.instance) {
// this.instance = new Calendar(date);
// }
// return this.instance;
// }
}
export default Calendar

1
components/qn-input-number/qn-input-number.vue

@ -2,7 +2,6 @@
<view class="wrapper">
<view class="minus-box" @tap="minusTap">
<uni-icons size="16" custom-prefix="iconfont" type="icon-Less" color="#007AFF"></uni-icons>
<!-- <uni-icons size="16" type="minus" color="#007AFF"></uni-icons> -->
</view>
<view class="" style="padding: 0rpx 4rpx">
<qn-easyinput

7
main.js

@ -1,11 +1,10 @@
import App from './App'
import pubFn from './common/js/publicFn.js'
import store from "./store";
import store from './store'
import Vue from 'vue'
Vue.config.productionTip = false
Vue.prototype.$store = store;
Vue.prototype.$store = store
App.mpType = 'app'
const app = new Vue({
...App
...App
})
app.$mount()

15
pages/add-account/index.vue

@ -48,7 +48,6 @@
<text class="add-paper-start"><uni-icons custom-prefix="iconfont" type="icon-required" size="14" color="#F5222D"></uni-icons></text>
<text class="add-paper-text">职务</text>
</view>
<!-- categoryId -->
<view class="">
<text v-if="form.title === ''" class="add-paph-text">点击选择职务</text>
<text v-else>{{ form.title }}</text>
@ -56,13 +55,12 @@
</view>
</view>
</view>
<view class="uploud-btn">
<view class="upload-btn">
<view class=""><button type="primary" class="btn-class" plain="true" @click="cencelList()">取消</button></view>
<view class=""><button type="primary" class="btn-class-upload" @click="uploadData()">确认</button></view>
</view>
<uni-popup ref="paperpopup" type="bottom">
<view class="popup_modal">
<!-- <slot name="title"><view class="popup_modal-title">选择纸种</view></slot> -->
<scroll-view scroll-y="true" class="popup_modal-scroll">
<view @click="paperSelectChange(item)" class="popup_modal-scroll-item" v-for="item in paperList" :key="item.id">{{ item.name }}</view>
<uGap></uGap>
@ -74,7 +72,7 @@
</template>
<script>
import { back, go2, uploadFile } from '@/utils/hook.js'
import { back } from '@/utils/hook.js'
import uGap from '@/components/u-gap/u-gap.vue'
import { addEmployee } from '@/apis/setting.js'
const validateFields = ['mobile', 'name', 'title']
@ -125,8 +123,8 @@ export default {
back()
},
uploadData() {
for (let i = 0; i < validateFields.length; i++) {
if (this.form[validateFields[i]] === null || this.form[validateFields[i]] === '') {
for (let validateField of validateFields) {
if (this.form[validateField] === null || this.form[validateField] === '') {
uni.showToast({
title: '请完善信息',
icon: 'none'
@ -134,10 +132,9 @@ export default {
return
}
}
var params = {
let params = {
...this.form,
enterpriseId: this.$store.state.companyInfo.id
// userId:this.$store.state.userInfo.userId,
}
addEmployee(params).then((res) => {
if (res) {
@ -256,7 +253,7 @@ export default {
line-height: 80rpx;
width: 200px;
}
.uploud-btn {
.upload-btn {
display: flex;
justify-content: space-between;
padding: 20rpx 32rpx;

5
pages/add-address-manage/index.vue

@ -32,7 +32,6 @@
<view class="qn-form-item">
<view class="label"><text class="label__text">所在地区</text></view>
<view class="value">
<!-- <qn-easyinput v-model="form.shortName" :inputBorder="false" text="right" placeholder="选择所在区域"></qn-easyinput> -->
<qn-data-picker
:readonly="hasSelected"
text="left"
@ -72,9 +71,6 @@
</view>
<qn-footer fixed height="120rpx">
<view class="button-area">
<!-- <view class="button button__cancel" @click="back">
<text class="text">取消</text>
</view> -->
<view class="button button__submit" @click="addTap"><text class="text" style="color: white">保存</text></view>
</view>
</qn-footer>
@ -164,7 +160,6 @@ export default {
switchChange(e) {
this.form.isDefault = e.target.value ? '1' : '0'
},
showCompany() {},
//
addTap() {
createAddress(this.form).then((res) => {

4
pages/address-manage/index.vue

@ -21,9 +21,6 @@
</view>
<qn-footer fixed height="120rpx">
<view class="button-area">
<!-- <view class="button button__cancel" @click="back">
<text class="text">取消</text>
</view> -->
<view class="button button__submit" @click="addTap"><text class="text" style="color: white">添加地址</text></view>
</view>
</qn-footer>
@ -197,7 +194,6 @@ export default {
display: flex;
flex-direction: row;
align-items: center;
// justify-content: space-between;
.button {
flex-grow: 0;
flex-shrink: 0;

37
pages/cart/index.vue

@ -22,7 +22,6 @@
:src="item.checkedGroup ? '/static/imgs/cart/shopping-cart-select.png' : '/static/imgs/cart/shopping-cart-not-select.png'"
mode=""
></image>
<!-- <checkbox-group @change="onCheck"><checkbox value="cb" :checked="checked" color="#000000" style="transform: scale(0.7)" /></checkbox-group> -->
</view>
<view class="">{{ item.supplierName }}</view>
</view>
@ -33,7 +32,6 @@
:src="subItem.checked ? '/static/imgs/cart/shopping-cart-select.png' : '/static/imgs/cart/shopping-cart-not-select.png'"
mode=""
></image>
<!-- <checkbox-group @change="onCheck"><checkbox value="cb" :checked="checked" color="#000000" style="transform: scale(0.7)" /></checkbox-group> -->
</view>
<view class="list-row">
<image
@ -82,9 +80,9 @@
</view>
<uni-popup ref="popup" type="center" :mask-click="false">
<view class="popup-box">
<view class="tip-title">{{ onlyQuantity ? '确定将当前纸品删除吗?' : (allSelected ? '确定将购物车纸品删除吗?' : '确定将当前纸品删除吗?') }}</view>
<view class="tip-title">{{ onlyQuantity ? '确定将当前纸品删除吗?' : allSelected ? '确定将购物车纸品删除吗?' : '确定将当前纸品删除吗?' }}</view>
<view class="operation-row">
<view class="cancel-text" @tap="cancelTap">{{onlyQuantity ? '我在想想' : '取消'}}</view>
<view class="cancel-text" @tap="cancelTap">{{ onlyQuantity ? '我在想想' : '取消' }}</view>
<view class="line"></view>
<view class="confirm-text" @tap="confirmTap">确定</view>
</view>
@ -124,7 +122,7 @@ export default {
checked: false,
list: [],
idList: [],
onlyQuantity: false,
onlyQuantity: false
}
},
created() {
@ -178,10 +176,6 @@ export default {
},
methods: {
go2,
//
seeDetailsTap(item) {
// go2('paper-details', { id: '681179176769818624' })
},
//
closeAnAccountTap() {
let orderGoodsList = []
@ -217,7 +211,6 @@ export default {
// purchaserEnterpriseId: '677166943471538176',
// userId: '573244119569272832',
}
// console.log('params', params)
closePaperReserve(params).then((res) => {
if (res) {
go2('order-make', { orderId: res.orderId })
@ -241,8 +234,6 @@ export default {
} else {
this.list = this.list.concat(res.records)
}
// this.list = []
// this.list = [...this.list, ...[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]
resolve({ list: this.list, total: res.total })
}
})
@ -291,8 +282,8 @@ export default {
//
isShopSelectedAll(products) {
let tempArr = true
for (var j = 0; j < products.length; j++) {
if (!products[j].checked) {
for (let product of products) {
if (product.checked) {
tempArr = false
break
}
@ -306,11 +297,11 @@ export default {
delTap() {
// idList
this.idList = []
let quantity = 0
let quantity = 0
this.list.forEach((el) => {
el.carItemList.forEach((good) => {
if (good.checked) {
quantity = good.quantity
quantity = good.quantity
this.idList.push(good.id)
}
})
@ -322,12 +313,12 @@ export default {
})
return
}
// 0
if(this.idList.length == 1 && quantity == 0) {
this.onlyQuantity = true
}else {
this.onlyQuantity = false
}
// 0
if (this.idList.length == 1 && quantity == 0) {
this.onlyQuantity = true
} else {
this.onlyQuantity = false
}
this.$refs.popup.open('center')
},
confirmTap() {
@ -356,8 +347,6 @@ export default {
change(num, shop, good) {
good.quantity = num
good.weight = round(good.gramWeight * good.width * good.length * good.quantity * 1e-12, 4)
// let buyTon = Number(good.gramWeight) * Number(good.quantity)
// good.weight = (buyTon / (1000 * 1000)).toFixed(4)
}
}
}

2
pages/cart/no-data.vue

@ -9,7 +9,7 @@
</template>
<script>
import { back, go2, loginG2 } from '@/utils/hook.js'
import { go2 } from '@/utils/hook.js'
export default {
props: {
title: {

27
pages/for-comparison/index.vue

@ -61,7 +61,6 @@
</view>
<view class="value">
<view class="value">
<!-- <qn-easyinput :maxlength="20" v-model="form.shortName" :inputBorder="false" text="right" placeholder="请输入数量"></qn-easyinput> -->
<radio-group>
<label v-for="(ritem, rindex) in radioGroupList" :key="rindex" @tap="specificationTap(ritem, rindex)">
<radio :checked="rindex === 0" style="transform: scale(0.7)" />
@ -99,21 +98,13 @@
placeholder="交货时间"
@change="deliveryTimeChange"
></qn-datetime-picker>
<!-- <picker :value="paperIndex" :range="deliveryTimeList" @change="deliveryTimeChange">
<view>
<text class="uni-input">{{ form.deliveryDay }}</text>
<uni-icons type="right" color="#000000" size="16"></uni-icons>
</view>
</picker> -->
</view>
</view>
<view class="qn-form-item qn-form-item" style="border: none">
<view class="label">
<!-- <uni-icons custom-prefix="iconfont" type="icon-required" size="14" color="#F5222D"></uni-icons> -->
<text class="label__text">交货区域</text>
</view>
<view class="value">
<!-- <qn-easyinput v-model="form.shortName" :inputBorder="false" text="right" placeholder="选择所在区域"></qn-easyinput> -->
<qn-data-picker
:readonly="hasSelected"
text="right"
@ -151,7 +142,6 @@
<qn-footer fixed height="120rpx">
<view class="button-area">
<!-- <view class="button button__cancel" @click="back"><text class="text">取消</text></view> -->
<view class="button button__submit" @click="addUser"><text class="text" style="color: white">提交询价</text></view>
</view>
</qn-footer>
@ -339,8 +329,8 @@ export default {
})
},
addUser() {
for (let i = 0; i < validateFields.length; i++) {
if (this.form[validateFields[i]] === null || this.form[validateFields[i]] === '') {
for (let validateField of validateFields) {
if (this.form[validateField] === null || this.form[validateField] === '') {
uni.showToast({
title: '请完善信息',
icon: 'none'
@ -399,19 +389,18 @@ export default {
* 获取当前时间的前一天 后一天 一周 或者是当前时间的几个小时
*/
getDay(day, hours) {
var today = new Date()
var targetday = today.getTime() + 1000 * 60 * 60 * 24 * day + hours
let today = new Date()
let targetday = today.getTime() + 1000 * 60 * 60 * 24 * day + hours
today.setTime(targetday)
var tYear = today.getFullYear()
var tMonth = today.getMonth()
var tDate = today.getDate()
var getHours = today.getHours()
let tYear = today.getFullYear()
let tMonth = today.getMonth()
let tDate = today.getDate()
tMonth = this.doHandleMonth(tMonth + 1)
tDate = this.doHandleMonth(tDate)
return tYear + '-' + tMonth + '-' + tDate + ' ' + '23:59:59'
},
doHandleMonth(month) {
var m = month
let m = month
if (month.toString().length === 1) {
m = '0' + month
}

12
store/index.js

@ -125,9 +125,9 @@ const store = new Vuex.Store({
console.error('userInfo必须是对象')
return
}
for (let i = 0; i < userInfoParams.length; i++) {
if (userInfo[userInfoParams[i]] === undefined) {
console.error('userInfo必须包含' + userInfoParams[i] + '属性')
for (let userInfoParam of userInfoParams) {
if (userInfo[userInfoParam] === undefined) {
console.error('userInfo必须包含' + userInfoParam + '属性')
return
}
}
@ -176,9 +176,9 @@ const store = new Vuex.Store({
console.error('companyInfo必须是对象')
return
}
for (let i = 0; i < companyInfoParams.length; i++) {
if (companyInfo[companyInfoParams[i]] === undefined) {
console.error(`companyInfo必须包含${companyInfoParams[i]}`)
for (let companyInfoParam of companyInfoParams) {
if (companyInfo[companyInfoParam] === undefined) {
console.error(`companyInfo必须包含${companyInfoParam}`)
return
}
}

6
utils/hook.js

@ -72,7 +72,7 @@ export function go2(url, data = {}, isRedirect = false) {
* @param {string} isRedirect 是否重定向 默认false
* @return {null}
*/
export function loginGo2(url, data = {}, isRedirect) {
export function loginGo2(url, data = {}, isRedirect = false) {
const token = store.state.qnToken
if (token) {
go2(url, data, isRedirect)
@ -109,8 +109,8 @@ export function uploadImage(sourceType = ['album', 'camera'], count = 1) {
return uploadFile(path, 'image')
})
Promise.all(cache)
.then((res) => {
resolve(res)
.then((urls) => {
resolve(urls)
})
.catch((err) => {
reject(err)

6
utils/index.js

@ -54,11 +54,6 @@ export const makeSocket = async ({ pageInfo = '', retry = false }) => {
async function createSocket() {
let url = ''
// if (env == 'production') {
// url = 'wss://api-client-yyt.qniao.cn/qn-websocket-service/wechatwebsock?token='
// } else if (env == 'test') {
// url = 'wss://api-client-yyt-test.qniao.cn/qn-websocket-service/wechatwebsock?token='
// }
if (env == 'production') {
url = 'wss://api-client-yyt.qniao.cn/trading-center/wechatwebsock?token='
} else if (env == 'test') {
@ -152,7 +147,6 @@ export const difTime = (time, target) => {
// 计算秒数
let seconds = Math.floor(diff / 1000)
seconds != seconds ? (seconds = 0) : ''
diff = diff % 1000
return {
beyond,
day,

Loading…
Cancel
Save