tianyi 3 weeks ago
parent
commit
379f7942fa
  1. 99
      components/common-loading/common-loading.vue
  2. 1
      components/kk-printer/index.vue
  3. 2
      main.js
  4. 1
      package1/buyFood/buyFood.vue
  5. 1
      package1/order/orderDetail.vue
  6. 1
      package1/order/orderEvaluate.vue
  7. 1
      package1/order/returnOrder.vue
  8. 1
      package1/runErrand/runErrand.vue
  9. 1
      package2/group/groupBuySingle.vue
  10. 1
      package2/group/shopEvaluate.vue
  11. 1
      package2/myCenter/addGoods.vue
  12. 1
      package2/myCenter/partTimeJobRegister.vue
  13. 1
      package2/shop/merchantRegister.vue
  14. 4
      pages/index/home.vue
  15. 5
      pages/index/index.vue
  16. 78
      utils/loading.js

99
components/common-loading/common-loading.vue

@ -0,0 +1,99 @@
<template>
<view
v-if="visible"
class="common-loading"
:class="{'common-loading--mask': mask}"
@touchmove.stop.prevent="noop"
@tap.stop="noop"
>
<view class="common-loading__box">
<image class="common-loading__gif" src="/static/images/img/loading.gif" mode="aspectFit"></image>
<view v-if="title" class="common-loading__text">{{ title }}</view>
</view>
</view>
</template>
<script>
import { LOADING_HIDE_EVENT, LOADING_SHOW_EVENT, getLoadingState } from '@/utils/loading.js'
export default {
name: 'CommonLoading',
data() {
return {
visible: false,
title: '加载中...',
mask: true
}
},
created() {
const state = getLoadingState()
this.visible = state.visible
this.title = state.title
this.mask = state.mask
uni.$on(LOADING_SHOW_EVENT, this.show)
uni.$on(LOADING_HIDE_EVENT, this.hide)
},
beforeDestroy() {
uni.$off(LOADING_SHOW_EVENT, this.show)
uni.$off(LOADING_HIDE_EVENT, this.hide)
},
methods: {
show(options = {}) {
this.visible = true
this.title = options.title || '加载中...'
this.mask = options.mask !== false
},
hide() {
this.visible = false
},
noop() {}
}
}
</script>
<style lang="scss" scoped>
.common-loading {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 99999;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
background: rgba(0, 0, 0, 0.18);
}
.common-loading--mask {
pointer-events: auto;
}
.common-loading__box {
min-width: 180rpx;
min-height: 180rpx;
padding: 34rpx 36rpx 30rpx;
border-radius: 28rpx;
background: rgba(255, 255, 255, 0.96);
box-shadow: 0 18rpx 46rpx rgba(0, 0, 0, 0.16);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.common-loading__gif {
width: 92rpx;
height: 92rpx;
}
.common-loading__text {
margin-top: 18rpx;
max-width: 320rpx;
font-size: 26rpx;
line-height: 36rpx;
color: #333;
text-align: center;
}
</style>

1
components/kk-printer/index.vue

@ -39,6 +39,7 @@
</view> </view>
</view> </view>
</view> </view>
<common-loading />
</view> </view>
</template> </template>

2
main.js

@ -3,6 +3,7 @@ import store from '@/store'
import App from './App' import App from './App'
import config from '@/config.js' import config from '@/config.js'
import uView from '@/uni_modules/uview-ui' import uView from '@/uni_modules/uview-ui'
import { installLoading } from '@/utils/loading.js'
import tui from './common/httpRequest' import tui from './common/httpRequest'
@ -10,6 +11,7 @@ Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
Vue.prototype.$ossDomain = config.OSS_DOMAIN Vue.prototype.$ossDomain = config.OSS_DOMAIN
Vue.use(uView) Vue.use(uView)
installLoading()

1
package1/buyFood/buyFood.vue

@ -422,6 +422,7 @@
<delivery-time-op @timeCallback="timeCallback" :dodge="true" ref='model' :content="content" :barHidth='600' <delivery-time-op @timeCallback="timeCallback" :dodge="true" ref='model' :content="content" :barHidth='600'
title="选择送达时间"> title="选择送达时间">
> </delivery-time-op> > </delivery-time-op>
<common-loading />
</view> </view>
</template> </template>

1
package1/order/orderDetail.vue

@ -746,6 +746,7 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<common-loading />
</view> </view>
</template> </template>

1
package1/order/orderEvaluate.vue

@ -131,6 +131,7 @@
</view> </view>
</view> </view>
</view> </view>
<common-loading />
</view> </view>
</template> </template>

1
package1/order/returnOrder.vue

@ -279,6 +279,7 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<common-loading />
</view> </view>
</template> </template>

1
package1/runErrand/runErrand.vue

@ -353,6 +353,7 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<common-loading />
</view> </view>
</template> </template>

1
package2/group/groupBuySingle.vue

@ -625,6 +625,7 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<common-loading />
</view> </view>
</template> </template>

1
package2/group/shopEvaluate.vue

@ -122,6 +122,7 @@
<img :src="bigImg" alt="" style="width: 100%;height: 100%;"> <img :src="bigImg" alt="" style="width: 100%;height: 100%;">
</view> </view>
</uni-popup> </uni-popup>
<common-loading />
</view> </view>
</template> </template>

1
package2/myCenter/addGoods.vue

@ -150,6 +150,7 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<common-loading />
</view> </view>
</template> </template>

1
package2/myCenter/partTimeJobRegister.vue

@ -205,6 +205,7 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<common-loading />
</view> </view>
</template> </template>

1
package2/shop/merchantRegister.vue

@ -178,6 +178,7 @@
<button @tap.stop="submit()">保存</button> <button @tap.stop="submit()">保存</button>
<common-loading />
</view> </view>
</template> </template>

4
pages/index/home.vue

@ -1,5 +1,7 @@
<template> <template>
<view>
<common-loading />
</view>
</template> </template>
<script> <script>

5
pages/index/index.vue

@ -962,10 +962,13 @@
if (res.code == 200) { if (res.code == 200) {
that.resetSwipeOrder(); that.resetSwipeOrder();
if (!uni.getStorageSync('worker') && res.result != null) { if (!uni.getStorageSync('worker') && res.result != null) {
that.tui.toast(res.message + '点击下方"配送"即可开始送单啦!');
uni.setStorageSync('worker', res.result) uni.setStorageSync('worker', res.result)
}else{
that.tui.toast(res.message);
} }
that.deliveryItem.splice(index, 1) that.deliveryItem.splice(index, 1)
that.tui.toast(res.message);
if (item.workerId != null && item.workerId != undefined && item.workerId != '') { if (item.workerId != null && item.workerId != undefined && item.workerId != '') {
that.zhipaiCount -= 1 that.zhipaiCount -= 1
} else { } else {

78
utils/loading.js

@ -0,0 +1,78 @@
export const LOADING_SHOW_EVENT = 'common-loading:show'
export const LOADING_HIDE_EVENT = 'common-loading:hide'
const defaultOptions = {
title: '加载中...',
mask: true
}
const loadingState = {
visible: false,
title: defaultOptions.title,
mask: defaultOptions.mask
}
let installed = false
let nativeShowLoading = null
let nativeHideLoading = null
function normalizeOptions(options = {}) {
if (typeof options === 'string') {
return {
...defaultOptions,
title: options
}
}
return {
...defaultOptions,
...options,
title: options.title || defaultOptions.title,
mask: options.mask !== false
}
}
export function getLoadingState() {
return {
...loadingState
}
}
export function showLoading(options) {
const loadingOptions = normalizeOptions(options)
loadingState.visible = true
loadingState.title = loadingOptions.title
loadingState.mask = loadingOptions.mask
uni.$emit(LOADING_SHOW_EVENT, loadingOptions)
loadingOptions.success && loadingOptions.success({ errMsg: 'showLoading:ok' })
loadingOptions.complete && loadingOptions.complete({ errMsg: 'showLoading:ok' })
}
export function hideLoading(options = {}) {
loadingState.visible = false
uni.$emit(LOADING_HIDE_EVENT)
nativeHideLoading && nativeHideLoading.call(uni)
options.success && options.success({ errMsg: 'hideLoading:ok' })
options.complete && options.complete({ errMsg: 'hideLoading:ok' })
}
export function installLoading() {
if (installed) {
return
}
installed = true
nativeShowLoading = uni.showLoading
nativeHideLoading = uni.hideLoading
uni.$nativeShowLoading = nativeShowLoading
uni.$nativeHideLoading = nativeHideLoading
uni.showLoading = showLoading
uni.hideLoading = hideLoading
}
export default {
installLoading,
showLoading,
hideLoading,
getLoadingState
}
Loading…
Cancel
Save