storeProductRelation.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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="/static/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/no_data.png',
  47. tip: '暂无数据'
  48. }
  49. },
  50. // 列表数据
  51. dataList: [],
  52. };
  53. },
  54. onLoad(option) {
  55. var that=this;
  56. },
  57. methods: {
  58. mescrollInit(mescroll) {
  59. this.mescroll = mescroll;
  60. },
  61. /*下拉刷新的回调 */
  62. downCallback(mescroll) {
  63. mescroll.resetUpScroll()
  64. },
  65. upCallback(page) {
  66. //联网加载数据
  67. var that = this;
  68. var data = {
  69. page: page.num,
  70. pageSize: page.size
  71. };
  72. getProductFoots(data).then(res => {
  73. if(res.code==200){
  74. //设置列表数据
  75. if (page.num == 1) {
  76. that.dataList = res.data.list;
  77. } else {
  78. that.dataList = that.dataList.concat(res.data.list);
  79. }
  80. that.mescroll.endBySize(res.data.list.length, res.data.total);
  81. }else{
  82. uni.showToast({
  83. icon:'none',
  84. title: "请求失败",
  85. });
  86. that.dataList = null;
  87. that.mescroll.endErr();
  88. }
  89. });
  90. },
  91. del(item){
  92. uni.showModal({
  93. title:"提示",
  94. content:"确认删除吗?",
  95. showCancel:true,
  96. cancelText:'取消',
  97. confirmText:'确定',
  98. success:res=>{
  99. if(res.confirm){
  100. // 用户点击确定
  101. var data={id:item.id}
  102. delProductFoots(data).then(
  103. res => {
  104. if(res.code==200){
  105. uni.showToast({
  106. icon:'success',
  107. title: "操作成功",
  108. });
  109. this.mescroll.resetUpScroll()
  110. }else{
  111. uni.showToast({
  112. icon:'none',
  113. title: "请求失败",
  114. });
  115. }
  116. },
  117. rej => {}
  118. );
  119. }else{
  120. // 否则点击了取消
  121. }
  122. }
  123. })
  124. },
  125. showDetail(item) {
  126. console.log(item)
  127. uni.navigateTo({
  128. url: '/pages/shopping/productDetails?productId=' + item.productId
  129. })
  130. },
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. .content{
  136. height: 100%;
  137. .goods-list{
  138. padding: 20upx;
  139. .item{
  140. box-sizing: border-box;
  141. height: 221upx;
  142. background: #FFFFFF;
  143. border-radius: 16upx;
  144. margin-bottom: 20upx;
  145. padding: 30upx;
  146. display: flex;
  147. align-items: center;
  148. &:last-child{
  149. margin-bottom: 0;
  150. }
  151. .goods-img{
  152. width: 160upx;
  153. height: 160upx;
  154. background: #FFFFFF;
  155. margin-right: 30upx;
  156. flex-shrink: 0;
  157. }
  158. .info-box{
  159. height: 160upx;
  160. display: flex;
  161. flex-direction: column;
  162. justify-content: space-between;
  163. width: calc(100% - 160upx);
  164. .title-box{
  165. width: 100%;
  166. display: flex;
  167. align-items: center;
  168. .title{
  169. flex: 1;
  170. font-size: 28upx;
  171. font-family: PingFang SC;
  172. font-weight: 500;
  173. color: #111111;
  174. line-height: 1;
  175. }
  176. }
  177. .prce-num{
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-between;
  181. margin-top: 30upx;
  182. .price{
  183. display: flex;
  184. align-items: flex-end;
  185. .unit{
  186. font-size: 24upx;
  187. font-family: PingFang SC;
  188. font-weight: 500;
  189. color: #FF6633;
  190. line-height: 1.2;
  191. margin-right: 4upx;
  192. }
  193. .num{
  194. font-size: 36upx;
  195. font-family: PingFang SC;
  196. font-weight: bold;
  197. color: #FF6633;
  198. line-height: 1;
  199. }
  200. }
  201. .operat-box{
  202. margin-right: 30rpx;
  203. display: flex;
  204. align-items: center;
  205. image{
  206. width: 30upx;
  207. height: 30upx;
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. </style>