storeProductRelation.vue 5.4 KB

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