list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <app-layout>
  3. <view class="list-head">
  4. <view class="dir-left-nowrap cross-center mch-list-input">
  5. <view class="box-grow-1 box dir-left main-center cross-center">
  6. <view v-if="toSearch" class="search-content">
  7. <input class="input"
  8. :value="keyword"
  9. @input="bindInput"
  10. @confirm="bindConfirm"
  11. @blur="beSearch"
  12. confirm-type="search"
  13. :focus="getFocus"/>
  14. <view v-if="keyword.length" @click="cancelPrint" class="main-center cross-center close-word">
  15. <icon class="icon-close"></icon>
  16. </view>
  17. </view>
  18. <view v-else @click="beSearch" class="main-center search-content cross-center">
  19. <icon class="icon-search"></icon>
  20. <text class="search-text">搜索</text>
  21. </view>
  22. </view>
  23. <view @click="changeCat" class="cross-center">
  24. <icon class="icon-cats"></icon>
  25. </view>
  26. </view>
  27. <view v-if="catModel" class="list-cat-model dir-left-wrap cross-center">
  28. <view v-for="(v,k) in cat_list" :key="k">
  29. <view @click="cat(v.id)">
  30. <view class="cat-name">{{v.name}}</view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="gap"></view>
  36. <app-good-shop-recommendation :theme="getTheme" :coupon_req="true" :mch_list="list" :show-goods="true"></app-good-shop-recommendation>
  37. <view class="no-content" v-if="!list || list.length === 0">暂无店铺记录</view>
  38. </app-layout>
  39. </template>
  40. <script>
  41. import appGoodShopRecommendation
  42. from '../../../components/page-component/app-good-shop-recommendation/app-good-shop-recommendation.vue';
  43. import {mapGetters} from "vuex";
  44. export default {
  45. name: "list",
  46. components: {appGoodShopRecommendation},
  47. data() {
  48. return {
  49. catModel: false,
  50. toSearch: false,
  51. list: [],
  52. cat_list: [],
  53. page: 1,
  54. keyword: '',
  55. mch_common_cat_id: 0,
  56. load: false,
  57. args: false,
  58. latitude: 0,
  59. longitude: 0,
  60. page_loading: false,
  61. getFocus: false
  62. }
  63. },
  64. onLoad: function (options) {
  65. this.getLocation();
  66. this.getCats();
  67. },
  68. onReachBottom: function () {
  69. const self = this;
  70. if (self.args || self.load)
  71. return;
  72. self.load = true;
  73. let page = self.page + 1;
  74. self.$request({
  75. url: self.$api.mch.index,
  76. data: {
  77. keyword: self.keyword,
  78. latitude: self.latitude,
  79. longitude: self.longitude,
  80. mch_common_cat_id: self.mch_common_cat_id,
  81. page: page,
  82. }
  83. }).then(info => {
  84. if (info.code === 0) {
  85. [self.page, self.args, self.list] = [page, info.data.list.length === 0, self.list.concat(self.dataMap(info.data.list))];
  86. }
  87. self.load = false;
  88. });
  89. },
  90. onShareAppMessage(e) {
  91. return this.$shareAppMessage({
  92. title: `好店推荐`,
  93. path: '/plugins/mch/list/list',
  94. params: {}
  95. });
  96. },
  97. methods: {
  98. dataMap(list) {
  99. if (!list)
  100. return;
  101. list.forEach(item => {
  102. item.pic_url = item.store.cover_url;
  103. item.name = item.store.name;
  104. item.goods_num = item.goods_count;
  105. item.order_num = item.order_goods_count;
  106. item.goodsList = item.goods;
  107. item.goodsList.forEach(item1 => {
  108. item1.picUrl = item1.goodsWarehouse.cover_pic;
  109. })
  110. });
  111. return list;
  112. },
  113. getLocation() {
  114. const self = this;
  115. uni.getLocation({
  116. type: 'wgs84',
  117. success(res) {
  118. [self.latitude, self.longitude] = [res.latitude, res.longitude];
  119. },
  120. complete() {
  121. self.loadData();
  122. }
  123. })
  124. },
  125. loadData() {
  126. const self = this;
  127. self.$showLoading();
  128. self.$request({
  129. url: self.$api.mch.index,
  130. data: {
  131. keyword: self.keyword,
  132. latitude: self.latitude,
  133. longitude: self.longitude,
  134. mch_common_cat_id: self.mch_common_cat_id,
  135. }
  136. }).then(info => {
  137. self.$hideLoading();
  138. if (info.code === 0) {
  139. self.list = self.dataMap(info.data.list);
  140. }
  141. }).catch(info => {
  142. self.$hideLoading();
  143. })
  144. },
  145. //分类处理
  146. getCats() {
  147. const self = this;
  148. self.$request({
  149. url: self.$api.mch.category,
  150. }).then(info => {
  151. self.cat_list = info.data.list;
  152. });
  153. },
  154. navShop(mch_id) {
  155. uni.navigateTo({url: `/plugins/mch/shop/shop?mch_id=` + mch_id});
  156. },
  157. navGoods(mch_id, goods_id) {
  158. uni.navigateTo({url: `/plugins/mch/goods/goods?id=` + goods_id + `&mch_id=` + mch_id});
  159. },
  160. beSearch: function (e) {
  161. if (this.keyword.length === 0) {
  162. this.toSearch = !this.toSearch;
  163. this.getFocus = this.toSearch;
  164. }
  165. },
  166. //搜索
  167. bindConfirm() {
  168. [
  169. this.page,
  170. this.mch_common_cat_id,
  171. this.catModel,
  172. this.list
  173. ] = [
  174. 1,
  175. 0,
  176. false,
  177. []
  178. ]
  179. this.loadData();
  180. },
  181. cat(id) {
  182. [this.mch_common_cat_id, this.list, this.page, this.catModel] = [id, [], 1, false];
  183. this.loadData();
  184. },
  185. changeCat() {
  186. this.catModel = !this.catModel;
  187. },
  188. bindInput: function (e) {
  189. this.keyword = e.detail.value;
  190. },
  191. cancelPrint() {
  192. this.keyword = '';
  193. this.toSearch = false;
  194. this.bindConfirm();
  195. },
  196. },
  197. computed: {
  198. ...mapGetters('mallConfig', {
  199. getTheme: 'getTheme',
  200. }),
  201. },
  202. }
  203. </script>
  204. <style scoped lang="scss">
  205. .search-content {
  206. height: #{56rpx};
  207. border-radius: #{28rpx};
  208. background: #fff;
  209. position: relative;
  210. width: 100%;
  211. margin-left: #{24rpx};
  212. .input {
  213. height: #{56rpx};
  214. border-radius: #{28rpx};
  215. color: #353535;
  216. width: 90%;
  217. background-color: #ffffff;
  218. }
  219. .icon-search {
  220. background-image: url("../../../static/image/icon/icon-search.png");
  221. height: #{24rpx};
  222. width: #{24rpx};
  223. background-size: 100% auto;
  224. margin-right: #{10rpx};
  225. background-repeat: no-repeat;
  226. }
  227. }
  228. .search-text {
  229. color: #b2b2b2;
  230. font-size: #{24rpx};
  231. margin: 0 #{5rpx};
  232. }
  233. .list-head {
  234. position: fixed;
  235. top: var(--window-top);
  236. z-index: 1;
  237. width: 100%;
  238. }
  239. .no-content {
  240. color: #888;
  241. padding: #{100rpx} 0 0 0;
  242. text-align: center;
  243. }
  244. .mch-list-input {
  245. height: #{88rpx};
  246. padding: 0 #{24rpx};
  247. background: #EFEFF4;
  248. .box {
  249. margin-right: #{24rpx};
  250. height: #{56rpx};
  251. border-radius: #{28rpx};
  252. background: #FFFFFF;
  253. input {
  254. border-radius: #{28rpx};
  255. }
  256. }
  257. .icon-cats {
  258. background-image: url("./../image/list-cat.png");
  259. background-repeat: no-repeat;
  260. background-size: 100% auto;
  261. height: #{30rpx};
  262. width: #{38rpx};
  263. }
  264. .close-word {
  265. height: #{56rpx};
  266. width: #{70rpx};
  267. position: absolute;
  268. right: 0;
  269. top: 0;
  270. z-index: 20;
  271. .icon-close {
  272. background-image: url("../../../static/image/icon/icon-close.png");
  273. background-repeat: no-repeat;
  274. background-size: 100% auto;
  275. height: #{25rpx};
  276. width: #{25rpx};
  277. }
  278. }
  279. }
  280. .list-cat-model {
  281. padding-top: #{12rpx};
  282. padding-bottom: #{12rpx};
  283. padding-left: #{20rpx};
  284. background: #f7f7f7;
  285. .cat-name {
  286. color: #353535;
  287. font-size: #{24rpx};
  288. border: #{1rpx} solid #e7e7e7;
  289. border-radius: #{28rpx};
  290. line-height: #{56rpx};
  291. height: #{56rpx};
  292. background: #ffffff;
  293. padding: 0 #{24rpx};
  294. margin: #{10rpx} #{12rpx} #{10rpx} #{12rpx};
  295. }
  296. }
  297. .gap {
  298. height: #{88rpx};
  299. }
  300. .list-shop {
  301. margin: #{10rpx} #{20rpx};
  302. width: #{710rpx};
  303. background: #fff;
  304. border-radius: #{16rpx};
  305. }
  306. .list-shop .shop-info {
  307. padding-right: #{24rpx};
  308. }
  309. .list-shop .distance {
  310. align-self: flex-start;
  311. padding-top: #{36rpx};
  312. font-size: #{24rpx};
  313. color: #999999;
  314. padding-right: #{50rpx};
  315. }
  316. .list-shop .list-shop-icon {
  317. border-radius: #{8rpx};
  318. height: #{100rpx};
  319. width: #{100rpx};
  320. margin: #{24rpx};
  321. }
  322. .list-shop .name {
  323. color: #353535;
  324. font-size: #{28rpx};
  325. margin-bottom: #{24rpx};
  326. }
  327. .list-shop .shop {
  328. font-size: #{24rpx};
  329. color: #999;
  330. }
  331. .list-shop .goods-num {
  332. padding-right: #{32rpx};
  333. }
  334. .list-shop .goods {
  335. padding-bottom: #{24rpx};
  336. margin: 0 #{16rpx};
  337. }
  338. .list-shop .goods-box {
  339. margin: 0 #{8rpx};
  340. }
  341. .list-shop .goods-info {
  342. position: relative;
  343. height: #{210rpx};
  344. width: #{210rpx};
  345. }
  346. .list-shop .goods-info view {
  347. background: #fff;
  348. font-size: #{28rpx};
  349. opacity: 0.8;
  350. width: #{210rpx};
  351. color: #ff4544;
  352. height: #{50rpx};
  353. position: absolute;
  354. bottom: 0;
  355. }
  356. .list-shop .goods-info image {
  357. height: 100%;
  358. width: 100%;
  359. }
  360. </style>