wish.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="page">
  3. <view class="mainBody">
  4. <scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll" scroll-left="0">
  5. <view class="item" :class="{'active':tab===0}" @click="checkTab(0)">
  6. <text class="left">全部</text>
  7. <view class="line"></view>
  8. </view>
  9. <view class="item" :class="{'active':tab===item.id}" @click="checkTab(item.id)"
  10. v-for="(item,index) in cate" :key="index">
  11. <text class="left">{{item.name}}</text>
  12. <view class="line"></view>
  13. </view>
  14. </scroll-view>
  15. </view>
  16. <view class="list_info">
  17. <block v-for="(item,index) in list" :key="index">
  18. <view class="item" @click="goDetail(item)">
  19. <view class="avator">
  20. <image class="icon" :src="item.image" mode="aspectFill">
  21. </image>
  22. </view>
  23. <view class="tit">
  24. <view class="name">{{item.name}}</view>
  25. <view class="desc" v-if="false">市场价:¥{{item.price}}</view>
  26. </view>
  27. <view class="list_mem">
  28. <image class="icon" v-for="(item2,index2) in item.mem_list" :src="item2.avator"
  29. mode="aspectFill" v-if="index2 < 8 && item2.avator != ''" />
  30. </view>
  31. <view class="btn_submit" @click="JoinIt(item)" v-if="item.status == 1">加入心愿</view>
  32. <view class="btn_submit gray" v-if="item.status == 2">已加入</view>
  33. </view>
  34. </block>
  35. <view class="blankHeight"></view>
  36. </view>
  37. <DialogBox ref="DialogBox"></DialogBox>
  38. <ToastW3 ref="ToastW3"></ToastW3>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. components: {},
  44. data() {
  45. return {
  46. tab: 0,
  47. scrollTop: 0,
  48. old: {
  49. scrollTop: 0
  50. },
  51. list: [],
  52. cate: [],
  53. }
  54. },
  55. onLoad() {},
  56. onShow() {
  57. this.loadData();
  58. },
  59. onNavigationBarButtonTap(e) {
  60. if (e.index === 0) {
  61. uni.navigateTo({
  62. url: '/pages/my/wishList'
  63. });
  64. }
  65. },
  66. methods: {
  67. onBack() {},
  68. checkTab(tab) {
  69. this.tab = tab;
  70. this.loadData();
  71. },
  72. scroll: function(e) {
  73. console.log(e)
  74. this.old.scrollTop = e.detail.scrollTop
  75. },
  76. goDetail(item) {
  77. uni.navigateTo({
  78. url: '/pages/my/wishDetail?id=' + item.id,
  79. })
  80. },
  81. loadData() {
  82. uni.request({
  83. url: this.$apiHost + '/Wish/getList',
  84. data: {
  85. uuid: getApp().globalData.uuid,
  86. cid: this.tab,
  87. },
  88. header: {
  89. 'content-type': 'application/json'
  90. },
  91. success: (res) => {
  92. console.log("res", res.data)
  93. this.list = res.data.list;
  94. this.cate = res.data.cate;
  95. }
  96. });
  97. },
  98. JoinIt(item) {
  99. let that = this;
  100. this.$refs['DialogBox'].confirm({
  101. title: '加入心愿',
  102. content: '是否确定加入心愿',
  103. DialogType: 'inquiry',
  104. btn1: '否',
  105. btn2: '是',
  106. animation: 0
  107. }).then((res) => {
  108. uni.request({
  109. url: this.$apiHost + "/Wish/joinit",
  110. data: {
  111. uuid: getApp().globalData.uuid,
  112. id: item.id
  113. },
  114. header: {
  115. "content-type": "application/json"
  116. },
  117. success: (res) => {
  118. console.log("----", res.data.list);
  119. // uni.showToast({
  120. // title: res.data.str,
  121. // icon: 'none'
  122. // })
  123. that.$refs['ToastW3'].showToast({
  124. title: res.data.str,
  125. animation: 0
  126. });
  127. if (res.data.success == "yes") {
  128. that.loadData()
  129. }
  130. },
  131. complete: (com) => {
  132. uni.hideLoading();
  133. },
  134. });
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style scoped lang="scss">
  141. @import 'wish.scss';
  142. </style>