wodezhuji.vue 10 KB

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