storeProductRelation.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="content">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  4. <view class="goods-list">
  5. <view class="item" v-for="(item,index) in dataList" :key="index" >
  6. <image @click="showDetail(item)" class="goods-img" :src="item.image" mode="aspectFit"></image>
  7. <view class="info-box">
  8. <view>
  9. <view class="title-box">
  10. <view class="title ellipsis">{{ item.productName }}</view>
  11. </view>
  12. </view>
  13. <view class="prce-num">
  14. <view class="price">
  15. <text class="unit">¥</text>
  16. <text class="num">{{item.price.toFixed(2)}} </text>
  17. </view>
  18. <view class="operat-box">
  19. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/del1.png" mode="" @click="del(item)"></image>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </mescroll-body>
  26. </view>
  27. </template>
  28. <script>
  29. import {delProductFoots,getProductFoots} from '@/api/user'
  30. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  31. export default {
  32. mixins: [MescrollMixin],
  33. data() {
  34. return {
  35. mescroll:null,
  36. // 上拉加载的配置
  37. upOption: {
  38. onScroll:true,
  39. use: true, // 是否启用上拉加载; 默认true
  40. page: {
  41. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  42. size: 10 // 每页数据的数量,默认10
  43. },
  44. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  45. empty: {
  46. icon:'/static/images/empty.png',
  47. tip: '暂无数据'
  48. }
  49. },
  50. downOption: { //下拉刷新
  51. use:true,
  52. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  53. },
  54. // 列表数据
  55. dataList: [],
  56. };
  57. },
  58. onLoad(option) {
  59. var that=this;
  60. },
  61. methods: {
  62. mescrollInit(mescroll) {
  63. this.mescroll = mescroll;
  64. },
  65. /*下拉刷新的回调 */
  66. downCallback(mescroll) {
  67. mescroll.resetUpScroll()
  68. },
  69. upCallback(page) {
  70. //联网加载数据
  71. var that = this;
  72. var data = {
  73. page: page.num,
  74. pageSize: page.size
  75. };
  76. getProductFoots(data).then(res => {
  77. if(res.code==200){
  78. //设置列表数据
  79. if (page.num == 1) {
  80. that.dataList = res.data.list;
  81. } else {
  82. that.dataList = that.dataList.concat(res.data.list);
  83. }
  84. that.mescroll.endBySize(res.data.list.length, res.data.total);
  85. }else{
  86. uni.showToast({
  87. icon:'none',
  88. title: "请求失败",
  89. });
  90. that.dataList = null;
  91. that.mescroll.endErr();
  92. }
  93. });
  94. },
  95. del(item){
  96. uni.showModal({
  97. title:"提示",
  98. content:"确认删除吗?",
  99. showCancel:true,
  100. cancelText:'取消',
  101. confirmText:'确定',
  102. success:res=>{
  103. if(res.confirm){
  104. // 用户点击确定
  105. var data={id:item.id}
  106. delProductFoots(data).then(
  107. res => {
  108. if(res.code==200){
  109. uni.showToast({
  110. icon:'success',
  111. title: "操作成功",
  112. });
  113. this.mescroll.resetUpScroll()
  114. }else{
  115. uni.showToast({
  116. icon:'none',
  117. title: "请求失败",
  118. });
  119. }
  120. },
  121. rej => {}
  122. );
  123. }else{
  124. // 否则点击了取消
  125. }
  126. }
  127. })
  128. },
  129. showDetail(item) {
  130. console.log(item)
  131. uni.navigateTo({
  132. url: '/pages/shopping/productDetails?productId=' + item.productId
  133. })
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. .content{
  140. height: 100%;
  141. .goods-list{
  142. padding: 20upx;
  143. .item{
  144. box-sizing: border-box;
  145. height: 221upx;
  146. background: #FFFFFF;
  147. border-radius: 16upx;
  148. margin-bottom: 20upx;
  149. padding: 30upx;
  150. display: flex;
  151. align-items: center;
  152. &:last-child{
  153. margin-bottom: 0;
  154. }
  155. .goods-img{
  156. width: 160upx;
  157. height: 160upx;
  158. background: #FFFFFF;
  159. margin-right: 30upx;
  160. flex-shrink: 0;
  161. }
  162. .info-box{
  163. height: 160upx;
  164. display: flex;
  165. flex-direction: column;
  166. justify-content: space-between;
  167. width: calc(100% - 160upx);
  168. .title-box{
  169. width: 100%;
  170. display: flex;
  171. align-items: center;
  172. .title{
  173. flex: 1;
  174. font-size: 28upx;
  175. font-family: PingFang SC;
  176. font-weight: 500;
  177. color: #111111;
  178. line-height: 1;
  179. }
  180. }
  181. .prce-num{
  182. display: flex;
  183. align-items: center;
  184. justify-content: space-between;
  185. margin-top: 30upx;
  186. .price{
  187. display: flex;
  188. align-items: flex-end;
  189. .unit{
  190. font-size: 24upx;
  191. font-family: PingFang SC;
  192. font-weight: 500;
  193. color: #FF6633;
  194. line-height: 1.2;
  195. margin-right: 4upx;
  196. }
  197. .num{
  198. font-size: 36upx;
  199. font-family: PingFang SC;
  200. font-weight: bold;
  201. color: #FF6633;
  202. line-height: 1;
  203. }
  204. }
  205. .operat-box{
  206. margin-right: 30rpx;
  207. display: flex;
  208. align-items: center;
  209. image{
  210. width: 30upx;
  211. height: 30upx;
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. }
  219. </style>