小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

197 lines
4.4 KiB

  1. <template>
  2. <view>
  3. <view class="storeBox" ref="container">
  4. <view
  5. class="storeBox-box"
  6. v-for="(item, index) in storeList"
  7. :key="index"
  8. @click="checked(item)"
  9. >
  10. <view class="store-img">
  11. <img :src="item.image" lazy-load="true" />
  12. </view>
  13. <view class="store-cent-left">
  14. <text class="store-name">{{ item.name }}</text>
  15. <text class="store-address line1">{{ item.address }}</text>
  16. </view>
  17. <view class="row-right">
  18. <view>
  19. <a class="store-phone" @click="telPhone(item.phone)">
  20. <text class="iconfont icon-dadianhua01"></text>
  21. </a>
  22. </view>
  23. <view class="store-distance" @click="showMaoLocation(item)">
  24. <text class="addressTxt" v-if="item.distance">距离{{ item.distance }}千米</text>
  25. <text class="addressTxt" v-else>查看地图</text>
  26. <text class="iconfont icon-youjian"></text>
  27. </view>
  28. </view>
  29. </view>
  30. <Loading :loaded="loaded" :loading="loading"></Loading>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import Loading from "@/components/Loading";
  36. import { storeListApi } from "@/api/store";
  37. import { isWeixin,tel } from "@/utils/index";
  38. import { wechatEvevt, wxShowLocation } from "@/libs/wechat";
  39. import { mapGetters } from "vuex";
  40. import cookie from "@/utils/store/cookie";
  41. const LONGITUDE = "user_longitude";
  42. const LATITUDE = "user_latitude";
  43. const MAPKEY = "mapKey";
  44. export default {
  45. name: "storeList",
  46. components: { Loading },
  47. computed: mapGetters(["location", "goName"]),
  48. data() {
  49. return {
  50. page: 1,
  51. limit: 20,
  52. loaded: false,
  53. loading: false,
  54. storeList: [],
  55. mapShow: false,
  56. system_store: {},
  57. mapKey: cookie.get(MAPKEY),
  58. locationShow: false
  59. };
  60. },
  61. mounted() {
  62. this.getList();
  63. },
  64. onReachBottom() {
  65. !this.loading && this.getOrderList();
  66. },
  67. methods: {
  68. showMaoLocation(data) {
  69. this.$yrouter.push({
  70. path: "/pages/map/index",
  71. query: data
  72. });
  73. },
  74. // 选中门店
  75. checked(e) {
  76. if (this.goName === "orders") {
  77. this.$store.commit("get_store", e);
  78. this.$yrouter.back();
  79. }
  80. },
  81. //拨打电话
  82. telPhone(phoneNumber) {
  83. uni.makePhoneCall({
  84. phoneNumber: phoneNumber,
  85. fail() {
  86. console.log("取消拨打");
  87. }
  88. });
  89. },
  90. // 获取门店列表数据
  91. getList: function() {
  92. if (this.loading || this.loaded) return;
  93. this.loading = true;
  94. let data = {
  95. latitude: this.location.latitude, //纬度
  96. longitude: this.location.longitude, //经度
  97. page: this.page,
  98. limit: this.limit
  99. };
  100. storeListApi(data)
  101. .then(res => {
  102. this.loading = false;
  103. this.loaded = res.data.list.length < this.limit;
  104. this.storeList.push.apply(this.storeList, res.data.list);
  105. this.page = this.page + 1;
  106. this.mapKey = res.data.mapKey;
  107. })
  108. .catch(err => {
  109. uni.showToast({
  110. title: err.msg,
  111. icon: "none",
  112. duration: 2000,
  113. });
  114. });
  115. }
  116. }
  117. };
  118. </script>
  119. <style scoped lang="less">
  120. .geoPage {
  121. position: fixed;
  122. width: 100%;
  123. height: 100%;
  124. top: 0;
  125. z-index: 10000;
  126. }
  127. .storeBox {
  128. background-color: #fff;
  129. padding: 0 0.3 * 100rpx;
  130. }
  131. .storeBox-box {
  132. width: 100%;
  133. height: auto;
  134. display: flex;
  135. align-items: center;
  136. padding: 0.23 * 100rpx 0;
  137. justify-content: space-between;
  138. border-bottom: 1px solid #eee;
  139. }
  140. .store-cent {
  141. display: flex;
  142. align-items: center;
  143. width: 80%;
  144. }
  145. .store-cent-left {
  146. width: 45%;
  147. text {
  148. display: block;
  149. }
  150. }
  151. .store-img {
  152. width: 1.2 * 100rpx;
  153. height: 1.2 * 100rpx;
  154. border-radius: 0.06 * 100rpx;
  155. margin-right: 0.22 * 100rpx;
  156. }
  157. .store-img img {
  158. width: 100%;
  159. height: 100%;
  160. }
  161. .store-name {
  162. color: #282828;
  163. font-size: 0.3 * 100rpx;
  164. margin-bottom: 0.22 * 100rpx;
  165. font-weight: 800;
  166. }
  167. .store-address {
  168. color: #666666;
  169. font-size: 0.24 * 100rpx;
  170. }
  171. .store-phone {
  172. width: 0.5 * 100rpx;
  173. height: 0.5 * 100rpx;
  174. color: #fff;
  175. border-radius: 50%;
  176. display: block;
  177. text-align: center;
  178. line-height: 0.5 * 100rpx;
  179. background-color: #e83323;
  180. margin-bottom: 0.22 * 100rpx;
  181. }
  182. .store-distance {
  183. font-size: 0.22 * 100rpx;
  184. color: #e83323;
  185. }
  186. .iconfont {
  187. font-size: 0.2 * 100rpx;
  188. }
  189. .row-right {
  190. display: flex;
  191. flex-direction: column;
  192. align-items: flex-end;
  193. width: 33.5%;
  194. }
  195. </style>