index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="container">
  3. <uni-nav-bar title="门店信息" backgroundColor='#03803B' color="#fff" left-icon="left" fixed statusBar
  4. @clickLeft='goBack()' @clickRight="addDetails" rightWidth="140rpx">
  5. <block slot="right">
  6. <view style="font-size: 26rpx;">
  7. <!-- <image class="nav-right" src="@/static/images/home/store/add.png" /> -->
  8. +添加门店
  9. </view>
  10. </block>
  11. </uni-nav-bar>
  12. <view style="background-color: #fff;">
  13. <uni-search-bar bgColor="#F6F6F6 " v-model="searchValue" placeholder="请输入店铺名称" @confirm="searchChange"
  14. cancelButton="none" @clear="searchChange">
  15. </uni-search-bar>
  16. </view>
  17. <z-paging ref="paging" v-model="dataList" @query="getList" :fixed="false" :auto-show-back-to-top="true"
  18. :empty-view-text="searchValue ? '未找到相关结果' : '暂无数据'" :hide-empty-view="false"
  19. :auto-show-system-loading="true">
  20. <view class="list">
  21. <view style="margin-top: 30rpx;" v-for="(item, index) in dataList" :key="index" @click="inEdit(item)">
  22. <uni-swipe-action>
  23. <uni-swipe-action-item>
  24. <view class="tab-bar-item">
  25. <image class="icon" :src="item.url" />
  26. <view class="text">
  27. <view class="text_title">
  28. <text style="color: #03803B;">店铺名称:</text>
  29. <text style="color: #6A6A6A" class='uni-lastmsg'>{{item.cname||'-'}}</text>
  30. </view>
  31. <view class="text_content">
  32. <text style="color: #03803B;">前置仓:</text>
  33. <text style="color: #6A6A6A"
  34. class='uni-lastmsg2'>{{item.deliveryWarehouseName||'暂无仓库'}}</text>
  35. <text style="color: #03803B;margin-left: 10rpx;">价格:</text>
  36. <text style="color: #6A6A6A"
  37. class='uni-lastmsg2'>¥{{item.priceSystem||0}}</text>
  38. </view>
  39. <view class="text_foot">
  40. <text style="color: #03803B;">电话:</text>
  41. <text style="color: #6A6A6A">{{item.tel}}</text>
  42. </view>
  43. </view>
  44. <view class="menu">
  45. <view class="">
  46. <image class="edit" src="@/static/images/home/store/edit.png" />
  47. </view>
  48. <view class="">
  49. <image class="QR" src="@/static/images/home/store/QR.png"
  50. @click.stop="inQR(item)" />
  51. </view>
  52. </view>
  53. </view>
  54. <template v-slot:right>
  55. <view @click.stop="onClick(item)"
  56. style="width: 120rpx;background-color:#e43d33;display: flex;justify-content: center;align-items: center;color: #fff;">
  57. <text>删除</text>
  58. </view>
  59. </template>
  60. </uni-swipe-action-item>
  61. </uni-swipe-action>
  62. </view>
  63. </view>
  64. </z-paging>
  65. <uni-popup ref="popup">
  66. <image style="width: 400rpx;height: 400rpx;background-color: #fff;" :src="imgPopup" />
  67. </uni-popup>
  68. </view>
  69. </template>
  70. <script>
  71. import {
  72. getList,
  73. remove,
  74. generateQrCode
  75. } from '@/api/home/store.js'
  76. export default {
  77. data() {
  78. return {
  79. searchValue: null,
  80. dataList: [],
  81. imgPopup: null,
  82. }
  83. },
  84. onLoad() {
  85. },
  86. onShow() {
  87. if (uni.getStorageSync('isUpdate')) {
  88. this.$nextTick(() => {
  89. if (this.$refs.paging) {
  90. this.$refs.paging.reload();
  91. }
  92. });
  93. uni.removeStorageSync('isUpdate')
  94. }
  95. },
  96. methods: {
  97. onClick(row) {
  98. let _this = this
  99. uni.showModal({
  100. title: '提示',
  101. content: '是否确认删除?',
  102. success: function(res) {
  103. if (res.confirm) {
  104. uni.showLoading({
  105. title: '加载中',
  106. mask: true
  107. });
  108. remove(row.id).then(res => {
  109. uni.showToast({
  110. title: '操作成功',
  111. icon: 'none',
  112. duration: 2000
  113. });
  114. _this.searchChange()
  115. })
  116. .finally(() => {
  117. uni.hideLoading()
  118. });
  119. }
  120. }
  121. });
  122. },
  123. addDetails() {
  124. uni.navigateTo({
  125. url: '/pages/home/store/details'
  126. });
  127. },
  128. inEdit(row) {
  129. uni.navigateTo({
  130. url: '/pages/home/store/details?id=' + row.id,
  131. });
  132. },
  133. inQR(row) {
  134. this.imgPopup = null
  135. uni.showLoading({
  136. title: '加载中',
  137. mask: true
  138. });
  139. generateQrCode({
  140. corpId: row.id
  141. }).then(res => {
  142. // uni.previewImage({
  143. // urls: [res.data.filePath],
  144. // });
  145. this.$refs.popup.open()
  146. this.imgPopup = res.data.filePath
  147. })
  148. .finally(() => {
  149. uni.hideLoading()
  150. });
  151. // uni.showToast({
  152. // title: '暂无二维码',
  153. // icon: 'none'
  154. // });
  155. },
  156. searchChange() {
  157. this.$refs.paging.reload()
  158. },
  159. async getList(pageNo, pageSize) {
  160. try {
  161. const obj = {
  162. retrieve: this.searchValue,
  163. current: pageNo,
  164. size: pageSize
  165. }
  166. const res = await getList(obj)
  167. this.$refs.paging.complete(res.data.records)
  168. } catch (e) {
  169. this.$refs.paging.complete(false)
  170. uni.showToast({
  171. title: '加载失败',
  172. icon: 'none'
  173. })
  174. }
  175. },
  176. goBack() {
  177. uni.navigateBack({
  178. delta: 1,
  179. });
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .scroll-view {
  186. flex: 1;
  187. height: 100%;
  188. /* 关键样式:防止内容被裁剪 */
  189. overflow-anchor: none;
  190. }
  191. .container {
  192. height: 100vh;
  193. display: flex;
  194. flex-direction: column;
  195. }
  196. .loading,
  197. .no-more {
  198. text-align: center;
  199. padding: 20px;
  200. color: #999;
  201. }
  202. .uni-lastmsg {
  203. width: 260rpx;
  204. white-space: nowrap;
  205. overflow: hidden;
  206. text-overflow: ellipsis;
  207. display: block;
  208. /* 需明确设置display */
  209. }
  210. .uni-lastmsg2 {
  211. width: 140rpx;
  212. white-space: nowrap;
  213. overflow: hidden;
  214. text-overflow: ellipsis;
  215. display: block;
  216. /* 需明确设置display */
  217. }
  218. .nav-right {
  219. width: 54rpx;
  220. height: 54rpx;
  221. }
  222. .list {
  223. width: 100%;
  224. .tab-bar-item {
  225. background-color: #fff;
  226. padding: 30rpx 62rpx;
  227. display: flex;
  228. .icon {
  229. width: 140rpx;
  230. height: 140rpx;
  231. // background: #909090;
  232. border-radius: 14rpx;
  233. }
  234. .text {
  235. padding: 0rpx 17rpx;
  236. display: flex;
  237. flex-direction: column;
  238. justify-content: space-between;
  239. height: 140rpx;
  240. .text_title {
  241. display: flex;
  242. height: 44rpx;
  243. font-weight: 500;
  244. font-size: 28rpx;
  245. color: #6A6A6A;
  246. }
  247. .text_content {
  248. display: flex;
  249. font-size: 28rpx;
  250. font-weight: 500;
  251. }
  252. .text_foot {
  253. font-size: 28rpx;
  254. font-weight: 500;
  255. }
  256. }
  257. .menu {
  258. position: absolute;
  259. right: 62rpx;
  260. .edit {
  261. margin-top: 10rpx;
  262. width: 30rpx;
  263. height: 33rpx;
  264. }
  265. .QR {
  266. margin-top: 54rpx;
  267. width: 30rpx;
  268. height: 31rpx;
  269. }
  270. }
  271. }
  272. }
  273. </style>