ChangeStore.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view :class="['qn-page-' + theme]">
  3. <view v-if="false"><map style="width: 750rpx; height: 450rpx;" :latitude="locationObj.latitude" :longitude="locationObj.longitude"></map></view>
  4. <view class="tabs-view" v-if="false">
  5. <u-tabs-swiper
  6. ref="tabs"
  7. :active-color="primaryColor"
  8. :bar-style="{ height: '6rpx', width: '60rpx' }"
  9. height="92"
  10. @change="tabsChange"
  11. :current="tab_current"
  12. :list="tab_list"
  13. :is-scroll="false"
  14. ></u-tabs-swiper>
  15. </view>
  16. <view class="store-ul">
  17. <view class="store-li clearfix" v-for="(item, index) in store_list" :key="index" @click="changeStore(item)">
  18. <view class="float_left">
  19. <image class="logo" :src="item.logo || 'https://onlineimg.qianniao.vip/161190485572831/5037749c8b9dbef2f1d8bc75bd1c1733/shop-ic.jpg'" mode="aspectFill"></image>
  20. </view>
  21. <view class="store-info float_left">
  22. <view class="store-name ellipsis">{{ item.name }}</view>
  23. <view class="other-info clearfix">
  24. <view class="float_left">
  25. <text class="ibonfont ibonshijian"></text>
  26. <text v-if="item.openTime.isAllDay">全天营业</text>
  27. <text v-else>{{ item.openTime.start }}-{{ item.openTime.end }}</text>
  28. </view>
  29. <view class="float_right juli">{{ item.meters || '' }}</view>
  30. </view>
  31. <view class="other-info">
  32. <u-icon name="map-fill" size="28"></u-icon>
  33. <text>{{ item.area.provinceName }}{{ item.area.cityName }}{{ item.area.districtName }}{{ item.area.address }}</text>
  34. </view>
  35. <view class="other-info status-info clearfix">
  36. <view class="float_left" style="margin-right: 20rpx;">
  37. <text class="success" v-if="item.enableStatus === 5">营业中</text>
  38. <text class="info" v-else>已打烊</text>
  39. </view>
  40. <view class="float_left" v-if="nowStore.id === item.id"><u-tag mode="dark" size="mini" text="当前店铺" type="success" /></view>
  41. <view class="float_right">
  42. <text>切换店铺</text>
  43. <text class="ibonfont ibonjinru"></text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <u-loadmore :status="loading_status" />
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. loading_status: 'nomore',
  57. tab_current: 0,
  58. tab_list: [{ name: '门店选择' }, { name: '常用/收藏' }],
  59. page: 1,
  60. pageSize: 10,
  61. store_list: [],
  62. pageTotal: 0
  63. };
  64. },
  65. computed: {
  66. locationObj() {
  67. return this.$store.state.locationObj;
  68. },
  69. // 获取当前门店数据
  70. nowStore() {
  71. return this.$store.state.nowStore;
  72. }
  73. },
  74. onLoad() {
  75. this.shopGetAll();
  76. },
  77. onReachBottom() {
  78. if (this.pageTotal / this.pageSize > this.page) {
  79. this.page += 1;
  80. this.shopGetAll();
  81. }
  82. },
  83. onPullDownRefresh() {
  84. uni.startPullDownRefresh();
  85. this.page = 1;
  86. this.shopGetAll();
  87. },
  88. methods: {
  89. shopGetAll() {
  90. this.$u.api
  91. .shopGetAll({
  92. page: this.page,
  93. pageSize: this.pageSize,
  94. longitude: this.locationObj.longitude, // 经度
  95. latitude: this.locationObj.latitude //纬度
  96. })
  97. .then(res => {
  98. uni.stopPullDownRefresh();
  99. if (this.page === 1) {
  100. this.store_list = res.data;
  101. } else {
  102. this.store_list = this.store_list.concat(res.data);
  103. }
  104. this.pageTotal = res.pageTotal;
  105. this.loading_status = this.$_utils.loadStatus(this.store_list.length, res.pageTotal);
  106. })
  107. .catch(() => {
  108. uni.stopPullDownRefresh();
  109. });
  110. },
  111. tabsChange(index) {
  112. this.tab_current = index;
  113. },
  114. changeStore(item) {
  115. let content = '确认切换到该门店吗?';
  116. if (this.nowStore.id === item.id) {
  117. content = '您选中的是当前所在店铺,是否返回上级页面继续下单?';
  118. }
  119. uni.showModal({
  120. title: '温馨提示',
  121. content: content,
  122. success: res => {
  123. if (res.confirm) {
  124. if (this.nowStore.id !== item.id) {
  125. this.$store.commit('commit_nowStore', item);
  126. }
  127. setTimeout(() => {
  128. uni.navigateBack();
  129. }, 500);
  130. } else if (res.cancel) {
  131. console.log('用户点击取消');
  132. }
  133. }
  134. });
  135. },
  136. phoneCall(mobile) {
  137. uni.makePhoneCall({
  138. phoneNumber: mobile
  139. });
  140. },
  141. openLocation(latitude, longitude) {
  142. uni.openLocation({
  143. latitude: latitude,
  144. longitude: longitude,
  145. name: this.locationObj.address,
  146. success: function() {
  147. console.log('success');
  148. }
  149. });
  150. }
  151. }
  152. };
  153. </script>
  154. <style lang="scss" scoped>
  155. .tabs-view {
  156. position: fixed;
  157. width: 100%;
  158. top: 0;
  159. left: 0;
  160. }
  161. .store-ul {
  162. padding: 0 20rpx;
  163. .store-li {
  164. padding: 20rpx;
  165. background-color: #ffffff;
  166. border-radius: 20rpx;
  167. margin: 20rpx 0;
  168. box-shadow: 2px 2px 7px 1px rgba(234, 232, 232, 0.5);
  169. .logo {
  170. display: block;
  171. width: 268rpx;
  172. height: 200rpx;
  173. border: 1px solid #f5f5f5;
  174. }
  175. .store-info {
  176. width: 376rpx;
  177. margin-left: 20rpx;
  178. position: relative;
  179. height: 200rpx;
  180. .store-name {
  181. width: 410rpx;
  182. -webkit-line-clamp: 1;
  183. margin-bottom: 8rpx;
  184. }
  185. .other-info {
  186. font-size: 24rpx;
  187. margin-top: 10rpx;
  188. color: #9d9d9d;
  189. .ibonfont {
  190. font-size: 22rpx;
  191. margin-right: 4rpx;
  192. display: inline-block;
  193. width: 28rpx;
  194. text-align: center;
  195. }
  196. }
  197. .status-info {
  198. position: absolute;
  199. bottom: 0;
  200. width: 100%;
  201. left: 0;
  202. color: #333333;
  203. .float_left {
  204. .success {
  205. color: $uni-color-success;
  206. }
  207. .info {
  208. color: #9d9d9d;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. </style>