shopTab.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="container">
  3. <view class="topNav flex">
  4. <image @click="backIndex" class="back" src="../../static/icon/back.png" mode="widthFix"></image>
  5. <view class="inputbox flex">
  6. <image class="search" src="../../static/icon/search.png" mode="widthFix"></image>
  7. <input class="input" confirm-type='搜索' @confirm='searchData' placeholder="请输入城市或者门店" type="text"
  8. v-model="search" />
  9. </view>
  10. </view>
  11. <!-- <pickerAddress class="" @change="onCityClick">
  12. <view class="address flex">
  13. <view class="flex">
  14. <text class="text">{{province}}</text>
  15. <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image>
  16. </view>
  17. <view class="flex">
  18. <text class="text">{{city}}</text>
  19. <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image>
  20. </view>
  21. <view class="flex">
  22. <text class="text">{{district}}</text>
  23. <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image>
  24. </view>
  25. </view>
  26. </pickerAddress> -->
  27. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="storeList">
  28. <!-- 空白页 -->
  29. <!-- <empty v-if="loaded === true && orderList.length === 0"></empty> -->
  30. <!-- 订单列表 -->
  31. <view class="itemList">
  32. <view class="item flex" v-for="(item,index) in orderList" :key='index' @click="onChecked(item)">
  33. <view class="imgBox">
  34. <image class="logo" :src="item.image" mode="aspectFit"></image>
  35. </view>
  36. <view class="padding-l-20 flex-grow-true">
  37. <view class="title clamp flex">
  38. <view class="name">
  39. {{item.name}}
  40. </view>
  41. <view class="km">
  42. {{item.range<1?item.distance+'m':item.range+'km'}}
  43. </view>
  44. </view>
  45. <view class="flex addressBox margin-t-20">
  46. <image class="iconA margin-r-10" src="../../static/icon/shop.png" mode="">
  47. </image>
  48. <text class="clamp">
  49. {{item.address}}
  50. </text>
  51. </view>
  52. <view class="addressBox flex">
  53. <image class="iconA margin-r-10" src="../../static/icon/shopPhone.png" mode="">
  54. <text class="clamp">
  55. {{item.phone}}
  56. </text>
  57. </view>
  58. <view class="yysj">
  59. 营业时间:{{item.day_time}}
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <uni-load-more :status="loadingType"></uni-load-more>
  65. </scroll-view>
  66. </view>
  67. </template>
  68. <script>
  69. import {
  70. storeList,
  71. } from '@/api/product.js';
  72. import {
  73. mapMutations,
  74. mapState
  75. } from 'vuex';
  76. export default {
  77. computed: {
  78. ...mapState('user', ['address'])
  79. },
  80. data() {
  81. return {
  82. search: '', //查询内容
  83. loadingType: 'more',
  84. orderList: [],
  85. page: 1, //当前页数
  86. limit: 10, //每次信息条数
  87. province: '请选择', //省
  88. city: '请选择', //市
  89. district: '请选择', //区
  90. loaded: false,
  91. type: 0 ,//默认为切换商店,1为不切换
  92. select: 0,//0为不选择商店,1为选择商店
  93. };
  94. },
  95. onLoad: function(option) {
  96. console.log(option.type);
  97. if (option.type) {
  98. this.type = option.type;
  99. }
  100. if(option.select) {
  101. this.select = option.select;
  102. }
  103. this.storeList();
  104. },
  105. methods: {
  106. ...mapMutations('shop', ['setShopInfo']),
  107. toJSON() {
  108. return this;
  109. },
  110. backIndex() {
  111. uni.switchTab({
  112. url: '/pages/index/index'
  113. })
  114. },
  115. // 查询方法
  116. searchData() {
  117. // 初始化数据重新搜索
  118. this.loaded = false;
  119. this.page = 1;
  120. this.orderList = [];
  121. this.loadingType = 'more';
  122. this.storeList()
  123. },
  124. // 存储当前的门店
  125. onChecked(item) {
  126. // if (this.type == 0) {
  127. // this.setShopInfo(item);
  128. // uni.showToast({
  129. // title: '切换成功',
  130. // mask: true,
  131. // duration: 1500
  132. // });
  133. // setTimeout((e) => {
  134. // uni.switchTab({
  135. // url: '/pages/index/index'
  136. // })
  137. // }, 1500)
  138. // }
  139. // console.log();
  140. // if (+this.type == 1) {
  141. // this.setShopInfo(item);
  142. // uni.navigateTo({
  143. // url: '/pages/shop/shopIndex?id=' + item.id
  144. // })
  145. // }
  146. let that = this
  147. if(that.select == 1) {
  148. let prepage = that.$api.prePage();
  149. prepage.selctStore = item
  150. uni.navigateBack()
  151. }
  152. },
  153. storeList(source) {
  154. //这里是将订单挂载到tab列表下
  155. let navItem = this;
  156. if (source === 'tabChange' && navItem.loaded === true) {
  157. //tab切换只有第一次需要加载数据
  158. return;
  159. }
  160. if (navItem.loadingType === 'loading') {
  161. //防止重复加载
  162. return;
  163. }
  164. if (navItem.loadingType === 'noMore') {
  165. //防止重复加载
  166. return;
  167. }
  168. // 修改当前对象状态为加载中
  169. navItem.loadingType = 'loading';
  170. let city = `${this.province},${this.city},${this.district}`;
  171. if (this.province == '请选择') {
  172. city = '';
  173. }
  174. storeList({
  175. city,
  176. page: navItem.page,
  177. limit: navItem.limit,
  178. key: this.search,
  179. latitude: this.address.latitude,
  180. longitude: this.address.longitude,
  181. })
  182. .then(({
  183. data
  184. }) => {
  185. let arr = data.list.map(e => {
  186. return e;
  187. });
  188. navItem.orderList = navItem.orderList.concat(arr);
  189. // console.log(navItem.orderList);
  190. navItem.page++;
  191. if (navItem.limit == arr.length) {
  192. //判断是否还有数据, 有改为 more, 没有改为noMore
  193. navItem.loadingType = 'more';
  194. return;
  195. } else {
  196. //判断是否还有数据, 有改为 more, 没有改为noMore
  197. navItem.loadingType = 'noMore';
  198. }
  199. uni.hideLoading();
  200. this.$set(navItem, 'loaded', true);
  201. console.log(this, '结果');
  202. })
  203. .catch(e => {
  204. console.log(e);
  205. });
  206. },
  207. // 内容改变事件
  208. onCityClick(item) {
  209. const arr = item.data;
  210. this.province = arr[0];
  211. this.city = arr[1];
  212. this.district = arr[2];
  213. // 开始查询
  214. console.log(this.province, this.city, this.district);
  215. console.log(arr);
  216. this.searchData()
  217. }
  218. },
  219. };
  220. </script>
  221. <style lang="scss">
  222. page,
  223. .container {
  224. height: 100%;
  225. }
  226. /* #ifdef APP */
  227. .container {
  228. padding-top: var(--status-bar-height);
  229. }
  230. /* #endif */
  231. .list-scroll-content {
  232. height: calc(100% - 44px);
  233. position: relative;
  234. overflow: hidden;
  235. z-index: 100;
  236. }
  237. .itemList {
  238. padding: 30rpx $page-row-spacing;
  239. .item {
  240. background-color: #FFFFFF;
  241. margin-bottom: 30rpx;
  242. padding: 30rpx;
  243. border-radius: 20rpx;
  244. .list,.km{
  245. color: $font-color-light;
  246. font-size: $font-sm;
  247. }
  248. .logo {
  249. height: 200rpx;
  250. width: 200rpx;
  251. border-radius: 20rpx;
  252. }
  253. .title {
  254. font-size: 36rpx;
  255. color: $font-color-dark;
  256. }
  257. .iconR {
  258. height: 24rpx;
  259. }
  260. .iconA {
  261. width: 24rpx;
  262. height: 24rpx;
  263. }
  264. .addressBox {
  265. font-size: 24rpx;
  266. color: $font-color-light;
  267. justify-content: flex-start;
  268. padding: 10rpx 0;
  269. }
  270. .yysj {
  271. display: inline-block;
  272. // width: 239rpx;
  273. padding: 0 10rpx;
  274. height: 32rpx;
  275. background: #ddf8f1;
  276. border-radius: 16rpx 16rpx 16rpx 0rpx;
  277. font-size: 20rpx;
  278. font-weight: bold;
  279. color: #5FCCA7;
  280. text-align: center;
  281. line-height: 32rpx;
  282. margin-top: 10rpx;
  283. }
  284. }
  285. }
  286. .address {
  287. background-color: #FFFFFF;
  288. justify-content: space-around;
  289. height: 40px;
  290. .text {
  291. font-size: 22rpx;
  292. color: $font-color-dark;
  293. margin-right: 5px;
  294. }
  295. .tipButtom {
  296. width: 11px;
  297. }
  298. }
  299. .topNav {
  300. height: 44px;
  301. background-color: #FFFFFF;
  302. padding: 0 15px;
  303. /* #ifdef MP */
  304. height:calc(44px + var(--status-bar-height)) ;
  305. padding-top: calc(var(--status-bar-height) - 15px);
  306. /* #endif */
  307. .back {
  308. width: 13px;
  309. }
  310. .inputbox {
  311. background-color: $page-color-base;
  312. height: 15px;
  313. flex-grow: 1;
  314. margin-left: 15px;
  315. border-radius: 50px;
  316. height: 30px;
  317. padding-left: 20px;
  318. /* #ifdef MP */
  319. margin-right: 200rpx;
  320. /* #endif */
  321. font-size: $font-base;
  322. .search {
  323. width: 18px;
  324. }
  325. .input {
  326. height: 100%;
  327. width: 100%;
  328. text-align: left;
  329. padding-left: 10px;
  330. }
  331. }
  332. }
  333. </style>