wodezhuji.vue 9.7 KB

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