index.vue 6.8 KB

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