storeList.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="content-store">
  3. <view class="input-search">
  4. <u-search placeholder="请输入店铺名称/电话号码" class="search" :show-action="false" input-align="center" v-model="queryWord" @input="getRow(1)"></u-search>
  5. </view>
  6. <scroll-view scroll-y class="list" @scrolltolower="onreachBottom">
  7. <view class="list-item flex align_center" v-for="item in list" :key="item.id" @click="addStore(item.id)">
  8. <u-image :src="item.reverseReceiveAddress &&item.reverseReceiveAddress.headerImageList?item.reverseReceiveAddress.headerImageList[0]:'/static/home_shop.png'" width="160" height="160"></u-image>
  9. <view class="item-right flex_1 flex justify_between align_center">
  10. <view class="right-item flex flex_column">
  11. <view >{{item.name}}</view>
  12. <view>{{item.mobile}}</view>
  13. <view>{{item.address}}</view>
  14. </view>
  15. <u-icon name="arrow-right" color="#9DA8B5" font-size="30"></u-icon>
  16. </view>
  17. </view>
  18. <view class="nodata flex justify_center align_center" v-if="list.length==0 && status!='loading'">
  19. <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260" ></u-empty>
  20. </view>
  21. <view v-if="index==current" style="padding: 20upx;">
  22. <u-loadmore v-if="total>pageSize || status=='loading'" :status="status" />
  23. </view>
  24. </scroll-view>
  25. <view class="footer" @click="addStore()">
  26. <view class="add-btn flex justify_center align_center">新增店铺</view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { shopList } from '@/api/shop.js'
  32. export default {
  33. data() {
  34. return {
  35. list: [], // 列表数据
  36. pageNo: 1, // 当前页码
  37. pageSize: 20, // 每页条数
  38. total: 0, // 数据总条数
  39. noDataText: '暂无数据', // 列表请求状态提示语
  40. status: 'loadmore', // 加载中状态
  41. queryWord:''
  42. }
  43. },
  44. onLoad() {
  45. this.pageInit()
  46. // 开启分享
  47. uni.showShareMenu({
  48. withShareTicket: true,
  49. menus: ['shareAppMessage', 'shareTimeline']
  50. })
  51. },
  52. onShow() {
  53. this.getRow(1)
  54. },
  55. methods: {
  56. pageInit() {
  57. this.pageNo = 1
  58. this.pageSize = 20
  59. this.total = 0
  60. this.list = []
  61. this.getRow(1)
  62. },
  63. // 打电话
  64. callPhone(phone) {
  65. uni.makePhoneCall({
  66. phoneNumber: phone
  67. });
  68. },
  69. // 进入详情
  70. intoDetail(item) {
  71. uni.navigateTo({
  72. url: '/pages/order/hisOrderDetail?orderNo='+item.orderReserveNo
  73. })
  74. },
  75. // scroll-view到底部加载更多
  76. onreachBottom() {
  77. this.action = 'onreachBottom'
  78. if (this.list.length < this.total) {
  79. this.pageNo += 1
  80. this.getRow()
  81. } else {
  82. if(this.list.length) {
  83. uni.showToast({
  84. title: '已经到底了',
  85. icon: 'none'
  86. });
  87. }
  88. this.status = "nomore"
  89. }
  90. },
  91. getArea(obj,state) {
  92. var index=obj.lastIndexOf("\市");
  93. if(state==0){
  94. obj=obj.substring(0,index);
  95. }else {
  96. obj=obj.substring(index+1,obj.length);
  97. }
  98. return obj;
  99. },
  100. // 查询列表
  101. getRow(pageNo) {
  102. this.status = "loadmore"
  103. if (pageNo) {
  104. this.pageNo = pageNo
  105. }
  106. let params = {
  107. pageNo: this.pageNo,
  108. pageSize: this.pageSize,
  109. queryWord:this.queryWord
  110. }
  111. this.noDataText = '暂无数据'
  112. this.status = "loading"
  113. shopList(params).then(res => {
  114. if (res.status == 200) {
  115. res.data.list.map(item=>{
  116. if(item.reverseReceiveAddress){
  117. if(item.reverseReceiveAddress.receiveAreasName){
  118. item.cityAddress=this.getArea(item.reverseReceiveAddress.receiveAreasName,1)
  119. }
  120. }
  121. console.log(item.cityAddress,'-----------item.cityAddress=============')
  122. item.address=item.reverseReceiveAddress ? ((item.reverseReceiveAddress.receiveAddress? item.reverseReceiveAddress.receiveAddress:'')+(item.cityAddress? '('+item.cityAddress+')':'')) : ''
  123. })
  124. if (this.pageNo > 1) {
  125. this.list = this.list.concat(res.data.list || [])
  126. } else {
  127. this.list = res.data.list || []
  128. }
  129. this.total = res.data.count || 0
  130. } else {
  131. this.list = []
  132. this.total = 0
  133. this.noDataText = res.message
  134. }
  135. this.status = "loadmore"
  136. })
  137. },
  138. // 新增店铺
  139. addStore(id){
  140. const storeId=id ? id : ''
  141. uni.navigateTo({
  142. url:`/pages/store/addStore?id=${storeId}`
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="less">
  149. .content-store{
  150. width: 100%;
  151. height: 100vh;
  152. background: #F5F5F5;
  153. box-sizing: border-box;
  154. display: flex;
  155. flex-direction: column;
  156. .input-search{
  157. width: 100%;
  158. height: 86upx;
  159. background-color: #fff;
  160. border-bottom: 1px solid #e5e5e5;
  161. // position: fixed;
  162. // top:0;
  163. // left:0;
  164. padding:14upx 32upx ;
  165. .search{
  166. width: 100%;
  167. border-radius: 18px;
  168. }
  169. }
  170. .list{
  171. flex: 1;
  172. overflow-y: scroll;
  173. .list-item{
  174. padding: 32upx;
  175. background-color: #fff;
  176. .item-right{
  177. margin-left:16upx;
  178. border-bottom: 1px solid #e5e5e5;
  179. .right-item{
  180. min-height: 160upx;
  181. view{
  182. min-height: 53upx;
  183. }
  184. }
  185. }
  186. }
  187. .nodata{
  188. padding-top: 30vh;
  189. }
  190. }
  191. .footer{
  192. width: 100%;
  193. padding: 14upx 32upx 32upx;
  194. background-color: #fff;
  195. color: #fff;
  196. font-weight: 500;
  197. .add-btn{
  198. height: 84upx;
  199. background: #1995FF;
  200. opacity: 1;
  201. border-radius: 16upx;
  202. }
  203. }
  204. }
  205. </style>