list.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <view class="container">
  3. <view class="dataList">
  4. <view class="search">
  5. <view class="tui-rolling-search">
  6. <tui-icon name="search-2" :size="32" unit="rpx"></tui-icon>
  7. <form @submit="searchSubmit">
  8. <input class="searchinput" placeholder="搜索" placeholder-class="placeholder"
  9. @confirm="searchSubmit" confirm-type="search" name="search"
  10. :value="where.keyword">
  11. </form>
  12. </view>
  13. </view>
  14. <view class="list acea-row row-between-wrapper">
  15. <block v-for="(item, index) in dataList" :key="index">
  16. <view @tap="selectTap" :data-item="item" class="item">
  17. <view class="text">
  18. <view class="nametitle">{{item.title}}</view>
  19. <view class="indicators">
  20. <text class="indctext">地址: {{item.province_name}}{{item.city_name}}{{item.district_name}}{{item.house_number}}</text>
  21. </view>
  22. </view>
  23. <view class="buttonbox">
  24. <view class="distance">
  25. <tui-icon name="position-fill" :size="16" color="#ff1e02"></tui-icon><text
  26. v-if="item.distance" class="kmclass">{{item.distance}}km</text>
  27. </view>
  28. <button class="itembutton">选择</button>
  29. </view>
  30. </view>
  31. </block>
  32. <view class="loadingicon acea-row row-center-wrapper" v-if="dataList.length > 0">
  33. <text class="loading iconfont icon-jiazai" :hidden="loading==false"></text>
  34. </view>
  35. </view>
  36. </view>
  37. <tui-tabbar :current="current">
  38. </tui-tabbar>
  39. </view>
  40. </template>
  41. <script>
  42. var app = getApp();
  43. export default {
  44. data() {
  45. return {
  46. current: '',
  47. dataList: [],
  48. navH: "",
  49. goodsid: '',
  50. where: {
  51. keyword: '',
  52. priceOrder: '',
  53. salesOrder: '',
  54. news: 0,
  55. page: 1,
  56. limit: 10,
  57. cid: 0,
  58. latitude: "",
  59. longitude: ""
  60. },
  61. price: 0,
  62. stock: 0,
  63. nows: false,
  64. loadend: false,
  65. loading: false,
  66. bottommenulist: [],
  67. host_product: "",
  68. title: "",
  69. position: "",
  70. latitude: "",
  71. longitude: "",
  72. cid: ""
  73. };
  74. },
  75. components: {},
  76. props: {},
  77. /**
  78. * 生命周期函数--监听页面加载
  79. */
  80. onLoad: function(options) {
  81. const _this = this; //位置授权
  82. this.where.cid = options.cid || ''
  83. this.goodsid = options.goodsid || ''
  84. // #ifdef MP-WEIXIN
  85. this.current = "/" + this.__route__;
  86. // #endif
  87. //#ifdef H5
  88. this.current = this.$route.path;
  89. //#endif
  90. _this.title = options.title || '';
  91. _this.where.keyword = options.searchValue || '';
  92. this.getPosition();
  93. },
  94. /**
  95. * 生命周期函数--监听页面显示
  96. */
  97. onShow: function() {},
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function() {
  102. this.where.page = 1;
  103. this.loadend = false;
  104. this.dataList = [];
  105. this.get_data_list();
  106. uni.stopPullDownRefresh();
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom: function() {
  112. this.get_data_list();
  113. },
  114. methods: {
  115. //获取定位信息
  116. getPosition() {
  117. const _this = this;
  118. // #ifdef MP-WEIXIN
  119. wx.authorize({
  120. scope: 'scope.userFuzzyLocation',
  121. success: res => {
  122. //console.log(res)
  123. wx.getFuzzyLocation({
  124. type: 'wgs84',
  125. success(res) {
  126. _this.position = res.address;
  127. _this.where.latitude = res.latitude;
  128. _this.where.longitude = res.longitude;
  129. _this.loadend = false;
  130. _this.get_data_list();
  131. }
  132. });
  133. },
  134. fail: res => {
  135. //console.log('失败:', res);
  136. }
  137. });
  138. // #endif
  139. //#ifdef H5 || APP-PLUS
  140. uni.getLocation({
  141. type: 'wgs84',
  142. success: function(lb) {
  143. _this.where.latitude = lb.latitude;
  144. _this.where.longitude = lb.longitude;
  145. _this.get_data_list();
  146. console.log(lb.longitude, lb.latitude);
  147. },
  148. })
  149. //#endif
  150. },
  151. selectTap: function(e) {
  152. const _this = this;
  153. var item = e.currentTarget.dataset.item;
  154. _this.$request.post('operatingcity.getcity', {
  155. samkey: (new Date()).valueOf(),
  156. city_id:item.id
  157. }).then(res => {
  158. uni.navigateBack({});
  159. });
  160. },
  161. searchSubmit: function(e) {
  162. var that = this;
  163. that.where.keyword = e.detail.value;
  164. that.where.page = 1;
  165. that.loadend = false;
  166. this.get_data_list(true);
  167. },
  168. //点击事件处理
  169. set_where: function(e) {
  170. this.cid = e.currentTarget.dataset.cid;
  171. this.loadend = false;
  172. this.where.page = 1;
  173. this.get_data_list(true);
  174. },
  175. //设置where条件
  176. setWhere: function() {
  177. this.where.salesOrder = 'asc';
  178. if (this.cid) {
  179. this.where.cid = this.cid;
  180. }
  181. },
  182. //查找
  183. get_data_list: function(isPage) {
  184. var that = this;
  185. this.setWhere();
  186. if (that.loadend) return;
  187. if (that.loading) return;
  188. if (isPage === true) {
  189. that.dataList = [];
  190. that.where.page =1;
  191. }
  192. that.where.samkey =(new Date()).valueOf();
  193. //console.log(that.where);
  194. that.$request.post('operatingcity.list', that.where).then(res => {
  195. var dataList = res.data.data;
  196. var loadend = dataList.length < that.where.limit;
  197. that.where.page = that.where.page + 1;
  198. that.loadend = loadend;
  199. that.loading = false;
  200. that.dataList = dataList;
  201. });
  202. }
  203. }
  204. };
  205. </script>
  206. <style>
  207. page {
  208. font-size: 28rpx;
  209. background-color: #f5f5f5;
  210. color: #333;
  211. }
  212. .container {
  213. padding-bottom: 228rpx;
  214. color: #333;
  215. }
  216. .dataList .search {
  217. width: 100%;
  218. padding-top: 13rpx;
  219. padding-bottom: 13rpx;
  220. padding-left: 15rpx;
  221. padding-right: 15rpx;
  222. box-sizing: border-box;
  223. align-items: center;
  224. background-color: #f5f5f5;
  225. position: fixed;
  226. display: flex;
  227. left: 0;
  228. z-index: 99999;
  229. }
  230. .searchinput {
  231. padding-left: 10rpx;
  232. }
  233. .tui-rolling-search {
  234. width: 100%;
  235. height: 66rpx;
  236. border-radius: 35rpx;
  237. padding: 0 40rpx 0 30rpx;
  238. box-sizing: border-box;
  239. background-color: #fff;
  240. display: flex;
  241. align-items: center;
  242. flex-wrap: nowrap;
  243. color: #999;
  244. }
  245. .tui-city-name {
  246. padding-left: 6rpx;
  247. padding-right: 0rpx;
  248. color: #333;
  249. font-size: 24rpx;
  250. line-height: 24rpx;
  251. }
  252. .tui-city-line {
  253. color: #d3d3d3;
  254. padding-left: 16rpx;
  255. padding-right: 20rpx;
  256. font-size: 24rpx;
  257. line-height: 24rpx;
  258. }
  259. .dataList .bg-color {
  260. background-color: #f5f5f5;
  261. }
  262. .dataList .search .location {
  263. color: #333;
  264. font-size: 28rpx;
  265. flex: 1;
  266. display: flex;
  267. margin-top: 22rpx;
  268. line-height: 40rpx;
  269. }
  270. .dataList .nav {
  271. width: 1000rpx;
  272. display: flex;
  273. color: #454545;
  274. font-size: 28rpx;
  275. background-color: #fff;
  276. }
  277. .dataList .nav .item {
  278. text-align: center;
  279. height: 100%;
  280. padding: 25rpx;
  281. }
  282. .dataList .nav .item.font-color {
  283. font-weight: bold;
  284. }
  285. .dataList .nav .item image {
  286. width: 88rpx;
  287. height: 88rpx;
  288. margin-left: 10rpx;
  289. }
  290. .dataList .list {
  291. padding: 20rpx;
  292. padding-top: 68rpx;
  293. margin-top: 6rpx;
  294. }
  295. .kmclass {
  296. padding-left: 5rpx;
  297. color: #333333;
  298. }
  299. .dataList .list .item {
  300. background-color: #fff;
  301. display: flex;
  302. margin-top: 20rpx;
  303. padding: 20rpx;
  304. border-radius: 18rpx;
  305. }
  306. .dataList .list .item .text {
  307. width: 100%;
  308. padding: 0 0 0 22rpx;
  309. font-size: 28rpx;
  310. color: #373333;
  311. }
  312. .dataList .list .item .text .money {
  313. font-size: 23rpx;
  314. margin-top: 50rpx;
  315. }
  316. .dataList .list .item .text .money .num {
  317. font-size: 32rpx;
  318. }
  319. .dataList .list .item .text .vip {
  320. font-size: 22rpx;
  321. color: #aaa;
  322. margin-top: 12rpx;
  323. }
  324. .dataList .list .item .text .vip .vip-money {
  325. font-size: 24rpx;
  326. color: #282828;
  327. font-weight: bold;
  328. }
  329. .dataList .list .item .text .vip .vip-money image {
  330. width: 46rpx;
  331. height: 21rpx;
  332. margin-left: 4rpx;
  333. }
  334. .dataList .list .item .buttonbox {
  335. margin-top: 40rpx;
  336. width: 200rpx;
  337. padding: 0 0 0 22rpx;
  338. font-size: 28rpx;
  339. color: #373333;
  340. }
  341. .nametitle {
  342. font-size: 32rpx;
  343. padding-top: 2rpx;
  344. word-break: break-all;
  345. font-weight: bold;
  346. overflow: hidden;
  347. text-overflow: ellipsis;
  348. display: -webkit-box;
  349. -webkit-box-orient: vertical;
  350. -webkit-line-clamp: 2;
  351. }
  352. .tztitle {
  353. font-size: 28rpx;
  354. margin-top: 10rpx;
  355. padding-top: 2rpx;
  356. word-break: break-all;
  357. overflow: hidden;
  358. text-overflow: ellipsis;
  359. display: -webkit-box;
  360. -webkit-box-orient: vertical;
  361. -webkit-line-clamp: 2;
  362. }
  363. .distance {
  364. text-align: center;
  365. }
  366. .itembutton {
  367. margin-top: 10rpx;
  368. font-size: 24rpx;
  369. color: #ffffff;
  370. align-items: center;
  371. background-color: #52c276;
  372. }
  373. .noCommodity {
  374. background-color: #fff;
  375. }
  376. .indicators {
  377. color: #909090;
  378. margin-top: 10rpx;
  379. }
  380. .belong {
  381. color: #909090;
  382. margin-top: 20rpx;
  383. }
  384. .indctext {
  385. padding-left: 3rpx;
  386. padding-right: 15rpx;
  387. }
  388. </style>