shangjia.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <!--
  3. 本页面模板教程:https://ext.dcloud.net.cn/plugin?id=2672
  4. uni-list 文档:https://ext.dcloud.net.cn/plugin?id=24
  5. uniCloud 文档:https://uniapp.dcloud.io/uniCloud/README
  6. unicloud-db 组件文档:https://uniapp.dcloud.io/uniCloud/unicloud-db
  7. DB Schema 规范:https://uniapp.dcloud.net.cn/uniCloud/schema
  8. -->
  9. <view class="list">
  10. <customNav :shownav="true" :title="$t('index.mendianliebiao')" titledetl=""></customNav>
  11. <!-- 刷新页面后的顶部提示框 -->
  12. <!-- 当前弹出内容没有实际逻辑 ,可根据当前业务修改弹出提示 -->
  13. <view class="tips" :class="{ 'tips-ani': tipShow }">{{$t('index.liebiaogengxin')}}</view>
  14. <!--
  15. <unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="formData" :collection="collection"
  16. :field="field" @load="load">
  17. -->
  18. <!-- 基于 uni-list 的页面布局 -->
  19. <uni-list>
  20. <!-- to 属性携带参数跳转详情页面,当前只为参考 -->
  21. <uni-list-item :border="false" class="uni-list-item--waterfall" v-for="(item,index) in mendianList"
  22. :key="index" v-on:click="gotoDetail(item.id)" :clickable="clickable">
  23. <view slot="body" class="shop">
  24. <view class="item_content">
  25. <imageconver :isremen="true" :isyouhui="false" :youhuinote="''" class="mainimage"
  26. :imagSrc="item.image"></imageconver>
  27. <!-- <image class="mainimage" :src="item.image=='/static/defimages/ddd.png'?item.image:baseUrl+item.image" mode="scaleToFill" @error="imageError(index)"></image> -->
  28. <view class="buyBTact">
  29. <text class="title">{{item.posName}}</text>
  30. <!-- <view class="viewinrow">
  31. <image class="xingxing" src="/static/images/xingxing@3x.png" mode="widthFix"></image>
  32. <text class="pingfentext">4.5</text>
  33. </view> -->
  34. </view>
  35. <view class="">
  36. <text class="Dishes">{{item.area}}</text>
  37. </view>
  38. <view class="contentInRowS">
  39. <text class="textfontB5">{{$t('index.manX')}}
  40. {{$formPr(item.posPrice)}}{{$t('locale.huobidw')}}</text>
  41. <text class="textfontB5" style="color:#00A6FF;">{{$formPr(item.juli)}}Km</text>
  42. </view>
  43. </view>
  44. </view>
  45. </uni-list-item>
  46. </uni-list>
  47. <!-- 通过 loadMore 组件实现上拉加载效果,如需自定义显示内容,可参考:https://ext.dcloud.net.cn/plugin?id=29 -->
  48. <uni-load-more v-if="loading || status === 'noMore' " :status="status" />
  49. <!--</unicloud-db>-->
  50. </view>
  51. </template>
  52. <script>
  53. import api from "@/pages/api/api.js";
  54. export default {
  55. components: {},
  56. data() {
  57. return {
  58. // 数据表名
  59. //collection: 'opendb-mall-goods',
  60. // 查询字段,多个字段用 , 分割
  61. //field: 'goods_thumb,name,goods_tip,tag,goods_price,comment_count,month_sell_count,shop_name',
  62. formData: {
  63. status: 'loading', // 加载状态
  64. },
  65. tipShow: false, // 是否显示顶部提示框
  66. data: '',
  67. mendianList: {},
  68. status: 'more',
  69. loading: true,
  70. latitude: 0,
  71. longitude: 0,
  72. typeID: '',
  73. serverType: '',
  74. clickable: true,
  75. page: 1,
  76. juli: 0
  77. };
  78. },
  79. onLoad(option) {
  80. console.log('option', option);
  81. var tempjuli = uni.getStorageSync('FuWujuli');
  82. if ('' == tempjuli || null == tempjuli || undefined == tempjuli) {
  83. this.juli = 10;
  84. } else {
  85. this.juli = tempjuli;
  86. }
  87. this.typeID = option.id;
  88. this.serverType = option.serverType;
  89. this.latitude = option.latitude;
  90. this.longitude = option.longitude;
  91. if (null == this.serverType || undefined == this.serverType || '' == this.serverType) {
  92. this.getmendianlist(1);
  93. this.status = 'more';
  94. } else {
  95. this.getserverlist(1);
  96. this.status = 'more';
  97. }
  98. this.formData.status = 'loading'
  99. },
  100. methods: {
  101. /*
  102. load(data, ended) {
  103. if (ended) {
  104. this.formData.status = 'noMore'
  105. }
  106. },
  107. */
  108. gotoDetail(e) {
  109. console.log(e);
  110. uni.navigateTo({
  111. url: '/pages/shanpinxungou/shangjia/shangjiaView?id=' + e
  112. })
  113. },
  114. getmendianlist(page) {
  115. this.tipShow = true;
  116. var data;
  117. if (null == this.typeID || undefined == this.typeID || '' == this.typeID) {
  118. data = {
  119. longitude: this.longitude,
  120. latitude: this.latitude,
  121. page: page,
  122. area: '',
  123. sort: '',
  124. juli: this.juli
  125. }
  126. } else {
  127. data = {
  128. longitude: this.longitude,
  129. latitude: this.latitude,
  130. page: page,
  131. area: '',
  132. sort: this.typeID,
  133. juli: this.juli
  134. }
  135. }
  136. //console.log(data)
  137. api('getmendianlist', data,
  138. r => {
  139. console.log(r.data.data);
  140. if (this.page == 1) {
  141. this.mendianList = r.data.data;
  142. } else {
  143. if (r.data.data && r.data.data.length > 0) {
  144. this.mendianList = this.mendianList.concat(r.data.data)
  145. } else {
  146. this.status = 'noMore';
  147. }
  148. }
  149. //console.log(this.mendianList)
  150. uni.stopPullDownRefresh()
  151. this.tipShow = false
  152. }, failc => {
  153. console.log(failc)
  154. uni.stopPullDownRefresh()
  155. this.tipShow = false
  156. })
  157. },
  158. getserverlist(page) {
  159. this.formData.status = 'more';
  160. this.tipShow = true;
  161. var data = {
  162. longitude: this.longitude,
  163. latitude: this.latitude,
  164. page: page,
  165. area: '',
  166. serverType: this.serverType,
  167. juli: this.juli
  168. };
  169. console.log('getserverlist', data);
  170. api('getaddressList', data,
  171. r => {
  172. console.log(r.data.data);
  173. if (this.page == 1) {
  174. this.mendianList = r.data.data;
  175. } else {
  176. if (r.data.data.length > 0) {
  177. var temp = this.mendianList;
  178. for (var i = 0; i < r.data.data.length; i++) {
  179. temp.push(r.data.data[i]);
  180. }
  181. this.mendianList = temp;
  182. } else {
  183. this.status = 'noMore';
  184. }
  185. }
  186. uni.stopPullDownRefresh()
  187. this.tipShow = false
  188. }, failc => {
  189. uni.stopPullDownRefresh()
  190. this.tipShow = false
  191. })
  192. },
  193. },
  194. /**
  195. * 下拉刷新回调函数
  196. */
  197. onPullDownRefresh() {
  198. this.getmendianlist(1);
  199. this.status = 'more';
  200. },
  201. /**
  202. * 上拉加载回调函数
  203. */
  204. onReachBottom() {
  205. this.page = this.page + 1;
  206. this.getmendianlist(this.page);
  207. },
  208. };
  209. </script>
  210. <style lang="scss">
  211. @import '@/common/uni-ui.scss';
  212. page {
  213. display: flex;
  214. flex-direction: column;
  215. box-sizing: border-box;
  216. background-color: #efeff4;
  217. min-height: 100%;
  218. height: auto;
  219. }
  220. .tips {
  221. color: #67c23a;
  222. font-size: 14px;
  223. line-height: 40px;
  224. text-align: center;
  225. background-color: #f0f9eb;
  226. height: 0;
  227. opacity: 0;
  228. transform: translateY(-100%);
  229. transition: all 0.3s;
  230. }
  231. .tips-ani {
  232. transform: translateY(0);
  233. height: 40px;
  234. opacity: 1;
  235. }
  236. .shop {
  237. flex: 1;
  238. display: flex;
  239. flex-direction: column;
  240. justify-content: space-between;
  241. }
  242. // 默认加入 scoped ,所以外面加一层提升权重
  243. .list {
  244. .uni-list--waterfall {
  245. /* #ifndef H5 || APP-VUE */
  246. // 小程序 编译后会多一层标签,而其他平台没有,所以需要特殊处理一下
  247. ::v-deep .uni-list {
  248. /* #endif */
  249. display: flex;
  250. flex-direction: row;
  251. flex-wrap: wrap;
  252. padding: 5rpx;
  253. box-sizing: border-box;
  254. /* #ifdef H5 || APP-VUE */
  255. // h5 和 app-vue 使用深度选择器,因为默认使用了 scoped ,所以样式会无法穿透
  256. ::v-deep
  257. /* #endif */
  258. .uni-list-item--waterfall {
  259. width: 50%;
  260. box-sizing: border-box;
  261. .uni-list-item__container {
  262. padding: 0rpx;
  263. flex-direction: column;
  264. }
  265. }
  266. /* #ifndef H5 || APP-VUE */
  267. }
  268. /* #endif */
  269. }
  270. }
  271. .item_content {
  272. background: white;
  273. width: 100%;
  274. height: 390rpx;
  275. margin-right: 20rpx;
  276. padding-top: 20rpx;
  277. padding-bottom: 20rpx;
  278. }
  279. .mainimage {
  280. width: 100%;
  281. height: 300rpx;
  282. display: block;
  283. border-radius: 0rpx;
  284. }
  285. .viewinrow {
  286. display: flex;
  287. flex-direction: row;
  288. justify-content: center;
  289. align-items: center;
  290. }
  291. .buyBTact {
  292. display: flex;
  293. flex-direction: row;
  294. justify-content: space-between;
  295. align-items: center;
  296. }
  297. .title {
  298. padding-top: 8rpx;
  299. width: 100%;
  300. text-align: left;
  301. font-size: 32rpx;
  302. line-height: 32rpx;
  303. font-weight: initial
  304. }
  305. .Dishes {
  306. width: 100%;
  307. text-align: left;
  308. font-size: 28rpx;
  309. line-height: 28rpx;
  310. color: darkgray;
  311. }
  312. .price {
  313. width: 100%;
  314. text-align: left;
  315. font-size: 28rpx;
  316. line-height: 28rpx;
  317. color: #E02F73;
  318. }
  319. .xingxing {
  320. width: 40rpx;
  321. height: 40rpx;
  322. }
  323. .pingfentext {
  324. width: 100%;
  325. text-align: left;
  326. font-size: 28rpx;
  327. line-height: 28rpx;
  328. color: black;
  329. }
  330. </style>