store_list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view class="container">
  3. <view class="dataList">
  4. <view class="search">
  5. <view class="tui-rolling-search">
  6. <tui-icon @tap="onChangePosition" name="position-fill" color="#333" :size="30" unit="rpx">
  7. </tui-icon>
  8. <view @tap="onChangePosition" class="tui-city-name">{{cityName}}</view>
  9. <tui-icon @tap="onChangePosition" name="turningdown" :size="32" unit="rpx"></tui-icon>
  10. <view class="tui-city-line">|</view>
  11. <tui-icon name="search-2" :size="32" unit="rpx"></tui-icon>
  12. <form @submit="searchSubmit">
  13. <input class="searchinput" placeholder="搜索" placeholder-class="placeholder"
  14. @confirm="searchSubmit" confirm-type="search" name="search" :value="where.keyword">
  15. </form>
  16. </view>
  17. </view>
  18. <scroll-view class="navscroll" scroll-x="true">
  19. <view class="nav acea-row row-middle">
  20. <block v-for="(item, index) in storecateList" :key="index">
  21. <view :class="'item ' + (cid==item.id ? 'font-color':'')" @tap="set_where" :data-cid="item.id">
  22. <view class="item-image">
  23. <image :src="item.icon"></image>
  24. </view>
  25. <view>{{item.title}}</view>
  26. </view>
  27. </block>
  28. </view>
  29. </scroll-view>
  30. <view :class="'list acea-row row-between-wrapper ' + (is_switch==true?'':'on')">
  31. <navigator v-for="(item, index) in dataList" :key="index" :class="'item ' + (is_switch==true?'':'on')"
  32. hover-class="none" :url="'/pages/store_details/store_details?id=' + item.id">
  33. <view :class="'pictrue ' + (is_switch==true?'':'on')">
  34. <image :src="item.store_logo" :class="is_switch==true?'':'on'"></image>
  35. </view>
  36. <view :class="'text ' + (is_switch==true?'':'on')">
  37. <view class="name line1">{{item.title}}</view>
  38. <view class="store-star">
  39. <image src="/static/images/star_32px.png"></image>
  40. <image src="/static/images/star_32px.png"></image>
  41. <image src="/static/images/star_32px.png"></image>
  42. <image src="/static/images/star_32px.png"></image>
  43. <image src="/static/images/star_32px.png"></image>
  44. </view>
  45. <view class="address">
  46. <image src="/static/images/address.png"
  47. style="margin-right: 10rpx;vertical-align: middle;width:30rpx; height: 30rpx;"></image>
  48. <text v-if="item.distance" class="kmclass">[{{item.distance}}km]</text>
  49. <block v-if="item.region_name">{{item.region_name}}</block>{{item.address}}
  50. </view>
  51. </view>
  52. </navigator>
  53. <view class="loadingicon acea-row row-center-wrapper" v-if="dataList.length > 0">
  54. <text class="loading iconfont icon-jiazai" :hidden="loading==false"></text>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="noCommodity" v-if="dataList.length==0 && where.page > 1">
  59. <view class="pictrue">
  60. </view>
  61. </view>
  62. <tui-tabbar :current="current" backgroundColor="#FFFFFF" color="#666" selectedColor="#EB0909">
  63. </tui-tabbar>
  64. </view>
  65. </template>
  66. <script>
  67. var app = getApp();
  68. export default {
  69. data() {
  70. return {
  71. lang:{},
  72. current: '',
  73. storecateList: [],
  74. dataList: [],
  75. cityName: '',
  76. navH: "",
  77. is_switch: false,
  78. where: {
  79. cid: 0,
  80. keyword: '',
  81. priceOrder: '',
  82. salesOrder: '',
  83. news: 0,
  84. page: 1,
  85. limit: 10,
  86. latitude: "",
  87. longitude: ""
  88. },
  89. price: 0,
  90. stock: 0,
  91. nows: false,
  92. loadend: false,
  93. loading: false,
  94. bottommenulist: [],
  95. host_product: "",
  96. title: "",
  97. position: "",
  98. latitude: "",
  99. longitude: "",
  100. cid: ""
  101. };
  102. },
  103. components: {},
  104. props: {},
  105. /**
  106. * 生命周期函数--监听页面加载
  107. */
  108. onLoad: function(options) {
  109. const _this = this;
  110. uni.setStorageSync('NewMessage', '');
  111. this.where.cid = options.cid || ''
  112. // #ifdef MP-WEIXIN
  113. this.current = "/" + this.__route__;
  114. // #endif
  115. //#ifdef H5
  116. this.current = this.$route.path;
  117. //#endif
  118. if (uni.getStorageSync('cityName')) {
  119. this.cityName = uni.getStorageSync('cityName');
  120. }
  121. _this.$request.get('Lang.getlang').then(res => {
  122. if (res.errno == 0) {
  123. _this.lang = res.data;
  124. uni.setNavigationBarTitle({
  125. title: _this.lang.store
  126. });
  127. }
  128. });
  129. //获取地置位置
  130. _this.sam.getCityPosition().then(res => {
  131. _this.cityName = res.cityName;
  132. });
  133. // #ifdef MP-WEIXIN
  134. wx.authorize({
  135. scope: 'scope.userFuzzyLocation',
  136. success: res => {
  137. //console.log(res)
  138. wx.getFuzzyLocation({
  139. type: 'wgs84',
  140. success(res) {
  141. _this.where.latitude = res.latitude;
  142. _this.where.longitude = res.longitude;
  143. _this.loadend = false;
  144. _this.title = options.title || '';
  145. _this.where.keyword = options.searchValue || '';
  146. _this.get_data_list();
  147. }
  148. });
  149. },
  150. fail: res => {
  151. //console.log('失败:', res);
  152. }
  153. });
  154. //#endif
  155. //#ifdef H5 || APP-PLUS
  156. uni.getLocation({
  157. type: 'wgs84',
  158. success: function(res) {
  159. //alert(res.latitude);
  160. _this.where.latitude = res.latitude;
  161. _this.where.longitude = res.longitude;
  162. _this.loadend = false;
  163. _this.title = options.title || '';
  164. _this.where.keyword = options.searchValue || '';
  165. _this.get_data_list();
  166. },
  167. })
  168. //#endif
  169. this.get_storecate_list();
  170. },
  171. /**
  172. * 生命周期函数--监听页面显示
  173. */
  174. onShow: function() {},
  175. /**
  176. * 页面相关事件处理函数--监听用户下拉动作
  177. */
  178. onPullDownRefresh: function() {
  179. this.where.page = 1;
  180. this.loadend = false;
  181. this.dataList = [];
  182. this.get_data_list();
  183. uni.stopPullDownRefresh();
  184. },
  185. /**
  186. * 页面上拉触底事件的处理函数
  187. */
  188. onReachBottom: function() {
  189. this.get_data_list();
  190. },
  191. methods: {
  192. onChangePosition: function(e) {
  193. const _this = this;
  194. uni.chooseLocation({
  195. success(res) {
  196. _this.cityName = res.name;
  197. uni.setStorageSync('cityName', _this.cityName);
  198. _this.position = res.address;
  199. _this.where.latitude = res.latitude;
  200. _this.where.longitude = res.longitude;
  201. _this.loadend = false;
  202. _this.latitude = res.latitude;
  203. _this.longitude = res.longitude;
  204. _this.get_data_list(true);
  205. }
  206. });
  207. },
  208. Changswitch: function() {
  209. var that = this;
  210. that.is_switch = !this.is_switch;
  211. },
  212. searchSubmit: function(e) {
  213. var that = this;
  214. that.where.keyword = e.detail.value;
  215. that.where.page = 1;
  216. that.loadend = false;
  217. this.get_data_list(true);
  218. },
  219. //点击事件处理
  220. set_where: function(e) {
  221. this.cid = e.currentTarget.dataset.cid;
  222. this.loadend = false;
  223. this.where.page = 1;
  224. this.get_data_list(true);
  225. },
  226. //设置where条件
  227. setWhere: function() {
  228. this.where.salesOrder = 'asc';
  229. if (this.cid) {
  230. this.where.cid = this.cid;
  231. }
  232. },
  233. get_storecate_list: function() {
  234. var that = this;
  235. that.$request.get('category.list').then(res => {
  236. that.storecateList = res.data;
  237. });
  238. },
  239. //查找店铺
  240. get_data_list: function(isPage) {
  241. var that = this;
  242. this.setWhere();
  243. if (that.loadend) return;
  244. if (that.loading) return;
  245. if (isPage === true) {
  246. that.dataList = [];
  247. that.where.page =1;
  248. }
  249. that.where.showLoading = true;
  250. //console.log(that.where);
  251. that.$request.post('store.list', that.where).then(res => {
  252. if (res.errno == 0) {
  253. that.dataList = that.dataList.concat(res.data);
  254. that.loadend = that.dataList.length < that.where.limit;
  255. that.loading = false;
  256. that.where.page = that.where.page + 1
  257. }
  258. });
  259. }
  260. }
  261. };
  262. </script>
  263. <style>
  264. page {
  265. font-size: 28rpx;
  266. background-color: #f5f5f5;
  267. color: #333;
  268. }
  269. .container {
  270. padding-bottom: 228rpx;
  271. color: #333;
  272. }
  273. .dataList .search {
  274. width: 100%;
  275. padding-top: 13rpx;
  276. padding-bottom: 13rpx;
  277. padding-left: 15rpx;
  278. padding-right: 15rpx;
  279. box-sizing: border-box;
  280. align-items: center;
  281. background-color: #f5f5f5;
  282. position: fixed;
  283. display: flex;
  284. left: 0;
  285. z-index: 99999;
  286. }
  287. .searchinput {
  288. padding-left: 10rpx;
  289. }
  290. .tui-rolling-search {
  291. width: 100%;
  292. height: 66rpx;
  293. border-radius: 35rpx;
  294. padding: 0 40rpx 0 30rpx;
  295. box-sizing: border-box;
  296. background-color: #fff;
  297. display: flex;
  298. align-items: center;
  299. flex-wrap: nowrap;
  300. color: #999;
  301. }
  302. .tui-city-name {
  303. padding-left: 6rpx;
  304. padding-right: 0rpx;
  305. color: #333;
  306. font-size: 24rpx;
  307. line-height: 24rpx;
  308. }
  309. .tui-city-line {
  310. color: #d3d3d3;
  311. padding-left: 16rpx;
  312. padding-right: 20rpx;
  313. font-size: 24rpx;
  314. line-height: 24rpx;
  315. }
  316. .dataList .bg-color {
  317. background-color: #f5f5f5;
  318. }
  319. .dataList .search .location {
  320. color: #333;
  321. font-size: 28rpx;
  322. flex: 1;
  323. display: flex;
  324. margin-top: 22rpx;
  325. line-height: 40rpx;
  326. }
  327. .navscroll {
  328. z-index: 99999;
  329. height: 188rpx;
  330. top: 91rpx;
  331. position: fixed;
  332. display: flex;
  333. white-space: nowrap;
  334. left: 0;
  335. background-color: #fff;
  336. }
  337. .dataList .nav {
  338. width: 1000rpx;
  339. display: flex;
  340. color: #454545;
  341. font-size: 28rpx;
  342. background-color: #fff;
  343. }
  344. .dataList .nav .item {
  345. text-align: center;
  346. height: 100%;
  347. padding: 25rpx;
  348. }
  349. .dataList .nav .item.font-color {
  350. font-weight: bold;
  351. }
  352. .dataList .nav .item image {
  353. width: 88rpx;
  354. height: 88rpx;
  355. margin-left: 10rpx;
  356. }
  357. .dataList .list {
  358. padding: 0 20rpx;
  359. padding-top: 276rpx;
  360. margin-top: 6rpx;
  361. }
  362. .kmclass {
  363. font-size: 28rpx;
  364. font-weight: normal;
  365. color: #909090;
  366. }
  367. .address {
  368. color: #909090;
  369. }
  370. .dataList .list.on {
  371. background-color: #fff;
  372. border-top: 1px solid #f6f6f6;
  373. }
  374. .dataList .list .item {
  375. width: 345rpx;
  376. margin-top: 20rpx;
  377. background-color: #fff;
  378. border-radius: 10rpx;
  379. }
  380. .dataList .list .item.on {
  381. width: 100%;
  382. display: flex;
  383. border-bottom: 1rpx solid #f6f6f6;
  384. padding: 30rpx 0;
  385. margin: 0;
  386. }
  387. .dataList .list .item .pictrue {
  388. width: 100%;
  389. height: 345rpx;
  390. }
  391. .dataList .list .item .pictrue.on {
  392. width: 180rpx;
  393. height: 180rpx;
  394. }
  395. .dataList .list .item .pictrue image {
  396. width: 100%;
  397. height: 100%;
  398. border-radius: 10rpx 10rpx 0 0;
  399. }
  400. .dataList .list .item .pictrue image.on {
  401. border-radius: 6rpx;
  402. }
  403. .dataList .list .item .text {
  404. padding: 20rpx 17rpx 26rpx 17rpx;
  405. font-size: 28rpx;
  406. color: #373333;
  407. }
  408. .dataList .list .item .text .name {
  409. font-size: 32rpx;
  410. font-weight: bold;
  411. }
  412. .dataList .list .item .text.on {
  413. width: 508rpx;
  414. padding: 0 0 0 22rpx;
  415. }
  416. .dataList .list .item .text .money {
  417. font-size: 23rpx;
  418. margin-top: 8rpx;
  419. }
  420. .dataList .list .item .text .money.on {
  421. margin-top: 50rpx;
  422. }
  423. .dataList .list .item .text .money .num {
  424. font-size: 32rpx;
  425. }
  426. .dataList .list .item .text .vip {
  427. font-size: 22rpx;
  428. color: #aaa;
  429. margin-top: 7rpx;
  430. }
  431. .dataList .list .item .text .vip.on {
  432. margin-top: 12rpx;
  433. }
  434. .dataList .list .item .text .vip .vip-money {
  435. font-size: 24rpx;
  436. color: #282828;
  437. font-weight: bold;
  438. }
  439. .dataList .list .item .text .vip .vip-money image {
  440. width: 46rpx;
  441. height: 21rpx;
  442. margin-left: 4rpx;
  443. }
  444. .noCommodity {
  445. background-color: #fff;
  446. }
  447. .store-star {
  448. margin-top: 10rpx;
  449. }
  450. .store-star image {
  451. width: 28rpx;
  452. height: 28rpx;
  453. }
  454. </style>