_quickConfig.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar title="快速入口设置">
  6. <!-- #ifndef MP-WEIXIN -->
  7. <button class="button white-btn" @click="handleSave">
  8. 保存
  9. </button>
  10. <!-- #endif -->
  11. </wk-nav-bar>
  12. <view class="container">
  13. <view class="section">
  14. <view class="section-title">
  15. <text class="section-title__text">
  16. 快速入口
  17. </text>
  18. <text class="section-title__desc">
  19. (长按拖动调整顺序)
  20. </text>
  21. </view>
  22. <!-- 目前版本中小程序slot兼容有神坑 -->
  23. <wk-drag-sort
  24. :list="quickList"
  25. class="wk-drag-sort"
  26. @sort="handleSort">
  27. <template v-slot:default="{ scopeData }">
  28. <view class="quick-item">
  29. <image :src="$static(scopeData.data.img)" class="img" />
  30. <text class="text">
  31. {{ scopeData.data.label }}
  32. </text>
  33. <image
  34. :src="$static('images/icon/status_invalid.png')"
  35. class="control-icon"
  36. @touchstart.stop
  37. @click.stop="handleRemove(scopeData.$index)" />
  38. </view>
  39. </template>
  40. <template v-if="quickList.length < 4">
  41. <view
  42. v-for="i in (4 - quickList.length)"
  43. :key="i"
  44. class="move-item empty" />
  45. </template>
  46. <view slot="move" slot-scope="scopeData" class="quick-item">
  47. <image
  48. :src="$static(scopeData.data.img)"
  49. class="img" />
  50. <text
  51. class="text">
  52. {{ scopeData.data.label }}
  53. </text>
  54. </view>
  55. </wk-drag-sort>
  56. </view>
  57. <view class="section">
  58. <view class="section-title">
  59. <text class="section-title__text">
  60. 全部
  61. </text>
  62. </view>
  63. <view class="section-body">
  64. <view
  65. v-for="item in otherList"
  66. :key="item.type"
  67. class="quick-item"
  68. @click="handleAdd(item)">
  69. <image :src="$static(item.img)" class="img" />
  70. <text class="text">
  71. {{ item.label }}
  72. </text>
  73. <image
  74. :src="$static('images/icon/add_primary.png')"
  75. class="control-icon" />
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- #ifdef MP-WEIXIN -->
  81. <view class="footer-btn-group">
  82. <button class="button" @click="handleSave">
  83. 保存
  84. </button>
  85. </view>
  86. <!-- #endif -->
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import { quickListLib, getQuickList } from './data.js'
  92. export default {
  93. name: 'HomeQuickConfig',
  94. data() {
  95. return {
  96. routerQuery: {},
  97. configList: ['customer', 'business', 'task', 'log']
  98. }
  99. },
  100. computed: {
  101. otherList() {
  102. return quickListLib.filter(o => !this.configList.includes(o.type))
  103. },
  104. quickList() {
  105. return getQuickList(this.configList)
  106. }
  107. },
  108. onLoad(options) {
  109. this.routerQuery = options
  110. this.initCom()
  111. },
  112. methods: {
  113. initCom() {
  114. },
  115. handleRemove(index) {
  116. this.configList.splice(index, 1)
  117. },
  118. handleSort(list) {
  119. this.configList = list.map(o => o.type)
  120. },
  121. handleAdd(item) {
  122. if (this.configList.length >= 4) {
  123. this.$toast('首页只能添加4个快捷入口')
  124. return
  125. }
  126. this.configList.push(item.type)
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. .container {
  133. flex: 1;
  134. .quick-item {
  135. position: relative;
  136. width: calc(25% - 20rpx);
  137. height: 150rpx;
  138. flex-direction: column;
  139. box-shadow: 0px 6rpx 18rpx rgba(232, 232, 233, 0.77);
  140. border-radius: 16rpx;
  141. background-color: white;
  142. margin: 10rpx;
  143. @include center;
  144. .img {
  145. width: 64rpx;
  146. height: 64rpx;
  147. }
  148. .text {
  149. font-size: $wk-font-mini;
  150. margin-top: 10rpx;
  151. }
  152. .control-icon {
  153. position: absolute;
  154. top: 5rpx;
  155. right: 5rpx;
  156. width: 36rpx;
  157. height: 36rpx;
  158. }
  159. &.empty {
  160. box-shadow: unset;
  161. border: 1rpx dashed #999999;
  162. }
  163. }
  164. .section {
  165. background-color: white;
  166. padding: 32rpx;
  167. .section-title {
  168. margin-bottom: 20rpx;
  169. .section-title__text {
  170. font-size: $wk-font-large;
  171. font-weight: bold;
  172. color: $dark;
  173. }
  174. .section-title__desc {
  175. font-size: $wk-font-base;
  176. color: $gray;
  177. }
  178. }
  179. .section-body {
  180. width: 100%;
  181. flex-wrap: wrap;
  182. @include left;
  183. }
  184. ::v-deep .wk-drag-sort {
  185. width: 100%;
  186. flex-wrap: wrap;
  187. @include left;
  188. .wk-drag-sort-item {
  189. width: calc(25% - 20rpx);
  190. height: 150rpx;
  191. margin: 10rpx;
  192. }
  193. .quick-item {
  194. width: 100%;
  195. height: 100%;
  196. margin: 0;
  197. }
  198. }
  199. }
  200. }
  201. </style>