list.vue 9.5 KB

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