inline_shop_car.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <view class="page">
  3. <!-- 购物车 -->
  4. <u-navbar title="购物车" :background="background" title-color="#ffffff" back-icon-color="#ffffff" is-fixed>
  5. <template slot="right">
  6. <text class="navbar-button" v-show="enbleEdit==false" @click="enbleEdit=true">编辑</text>
  7. <text class="navbar-button" v-show="enbleEdit==true" @click="enbleEdit=false">完成</text>
  8. </template>
  9. </u-navbar>
  10. <scroll-view scroll-y @scrolltolower="scrollBottom" class="scroll-view-container">
  11. <view class="page-box">
  12. <u-checkbox-group class="order" @change="checkboxGroupChange">
  13. <u-checkbox @change="checkboxChange" style="width: 100%;" v-model="item.checked" shape="circle" v-for="(item,index) in goodsList" :key="item.id" :name="item.id">
  14. <view class="item">
  15. <view class="left">
  16. <image :src="item.goodsUrl" mode="aspectFill"></image>
  17. </view>
  18. <view class="content">
  19. <view class="title u-line-2">{{ item.title }}</view>
  20. <view class="type">{{ item.type }}</view>
  21. <!-- <view class="delivery-time">发货时间 {{ item.deliveryTime }}</view> -->
  22. <view class="price-row">
  23. <view class="brand">
  24. {{ item.brand }}
  25. </view>
  26. <view class="demo-count-box">
  27. <u-number-box v-model="selectedCount" :min="1" @change="selectedCountChange"></u-number-box>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </u-checkbox>
  33. </u-checkbox-group>
  34. <u-loadmore :status="loadStatus" bgColor="#f2f2f2"></u-loadmore>
  35. </view>
  36. </scroll-view>
  37. <view class="navigation">
  38. <view class="left">
  39. <view class="item">
  40. <u-checkbox shape="circle" @change="checkedAll" v-model="checkedAllValue">全选</u-checkbox>
  41. </view>
  42. </view>
  43. <view class="right" v-show="enbleEdit==false">
  44. <view class="total">合计:<text>2条</text></view>
  45. <view class="buy btn u-line-1" @click="handleSubmit">立即下单</view>
  46. </view>
  47. <view class="right" v-show="enbleEdit==true">
  48. <view class="buy btn u-line-1" @click="handleDel">删除</view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. background: {
  58. backgroundColor: "#0291FD",
  59. color: "#ffffff"
  60. },
  61. buttonCustomStyle: {
  62. color: "#ffffff",
  63. background: "transparent",
  64. border: "none"
  65. },
  66. selectedCount: 0,
  67. checkedAllValue: false,
  68. enbleEdit: false,
  69. loadStatus: "false",
  70. goodsList: [],
  71. list: [{
  72. id: "1",
  73. goodsUrl: 'https://img12.360buyimg.com/n7/jfs/t16642/126/2693663818/450163/6879e8ce/5b06d93bN6305bd94.png',
  74. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  75. type: '胎动品牌;修补类型;普通积分',
  76. deliveryTime: '付款后30天内发货',
  77. price: '348.58',
  78. number: 2,
  79. checked: false,
  80. disabled: false,
  81. brand: "SAILUN"
  82. },
  83. {
  84. id: "2",
  85. goodsUrl: 'https://img12.360buyimg.com/n7/jfs/t1/47645/22/6120/140457/5d3d17deEec9f8e8d/3687ff03ca89b48c.jpg',
  86. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  87. type: '胎动品牌;修补类型;普通积分',
  88. deliveryTime: '付款后30天内发货',
  89. price: '135.00',
  90. number: 1,
  91. checked: false,
  92. disabled: false,
  93. brand: "SAILUN"
  94. },
  95. {
  96. id: "3",
  97. goodsUrl: 'https://img11.360buyimg.com/n7/jfs/t1/88990/24/4208/105799/5de4c6e9E24bc09d0/f810effb14c9c13a.jpg',
  98. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  99. type: '胎动品牌;修补类型;普通积分',
  100. deliveryTime: '付款后7天内发货',
  101. price: '128.05',
  102. number: 1,
  103. checked: false,
  104. disabled: false,
  105. brand: "SAILUN"
  106. },
  107. {
  108. id: "4",
  109. goodsUrl: 'https://img12.360buyimg.com/n7/jfs/t1/93698/23/4500/114562/5de713dfEfc997085/e8deaa979909851d.jpg',
  110. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  111. type: '胎动品牌;修补类型;普通积分',
  112. deliveryTime: '保质5年',
  113. price: '1998',
  114. number: 3,
  115. checked: false,
  116. disabled: false,
  117. brand: "SAILUN"
  118. },
  119. {
  120. id: "5",
  121. goodsUrl: 'https://img11.360buyimg.com/n7/jfs/t16642/126/2693663818/450163/6879e8ce/5b06d93bN6305bd94.png',
  122. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  123. type: '胎动品牌;修补类型;普通积分',
  124. deliveryTime: '保质5年',
  125. price: '2354',
  126. number: 1,
  127. checked: false,
  128. disabled: false,
  129. brand: "SAILUN"
  130. },
  131. {
  132. id: "6",
  133. goodsUrl: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  134. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  135. type: '胎动品牌;修补类型;普通积分',
  136. deliveryTime: '珍藏10年好酒',
  137. price: '1543',
  138. number: 3,
  139. checked: false,
  140. disabled: false,
  141. brand: "SAILUN"
  142. },
  143. {
  144. id: "7",
  145. goodsUrl: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  146. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  147. type: '胎动品牌;修补类型;普通积分',
  148. deliveryTime: '口感好',
  149. price: '120',
  150. number: 1,
  151. checked: false,
  152. disabled: false,
  153. brand: "SAILUN"
  154. },
  155. {
  156. id: "8",
  157. goodsUrl: 'https://img10.360buyimg.com/n7/jfs/t1/68753/35/2229/118427/5d089fb7Ee5b93887/2e3bbc7fec247fdc.jpg',
  158. title: '【胎动】T-M3蘑菇钉,24支/盒, 3mm ',
  159. type: '胎动品牌;修补类型;普通积分',
  160. deliveryTime: '使用方便',
  161. price: '451',
  162. number: 9,
  163. checked: false,
  164. disabled: false,
  165. brand: "SAILUN"
  166. }
  167. ]
  168. }
  169. },
  170. onLoad() {
  171. this.addRandomData();
  172. },
  173. methods: {
  174. scrollBottom: function() {
  175. this.loadStatus = 'loading';
  176. // 模拟数据加载
  177. setTimeout(() => {
  178. this.addRandomData();
  179. this.loadStatus = 'loadmore';
  180. }, 1000)
  181. },
  182. selectedCountChange: function(){},
  183. checkboxGroupChange: function(params) {
  184. console.log(1)
  185. console.log(params)
  186. },
  187. checkboxChange: function(params) {
  188. if(!params.value){
  189. this.checkedAllValue = false;
  190. }
  191. },
  192. checkedAll: function(params) {
  193. if(params.value){
  194. this.goodsList.map(val => {
  195. val.checked = true;
  196. })
  197. }else{
  198. this.goodsList.map(val => {
  199. val.checked = false;
  200. })
  201. }
  202. },
  203. handleSubmit: function(){
  204. uni.navigateTo({
  205. url: "/pages/home/shopping/integral_mall_confirmorder"
  206. })
  207. },
  208. handleDel: function(){},
  209. addRandomData() {
  210. for (let i = 0; i < 10; i++) {
  211. let index = this.$u.random(0, this.list.length - 1);
  212. // 先转成字符串再转成对象,避免数组对象引用导致数据混乱
  213. let item = JSON.parse(JSON.stringify(this.list[index]))
  214. item.id = this.$u.guid();
  215. if(this.checkedAllValue){
  216. item.checked = true;
  217. };
  218. this.goodsList.push(item);
  219. }
  220. },
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. .scroll-view-container{
  226. width: 100%;
  227. height: calc(100vh - 176rpx);
  228. }
  229. .navbar-button {
  230. padding: 24rpx 26rpx;
  231. display: inline-block;
  232. }
  233. .order {
  234. width: 710rpx;
  235. background-color: #ffffff;
  236. margin: 20rpx auto;
  237. border-radius: 20rpx;
  238. box-sizing: content-box;
  239. padding: 20rpx;
  240. font-size: 28rpx;
  241. .top {
  242. display: flex;
  243. justify-content: space-between;
  244. .left {
  245. display: flex;
  246. align-items: center;
  247. .store {
  248. margin: 0 10rpx;
  249. font-size: 32rpx;
  250. font-weight: bold;
  251. }
  252. }
  253. .right {
  254. color: $u-type-warning-dark;
  255. }
  256. }
  257. .item {
  258. display: flex;
  259. margin: 20rpx 0 0;
  260. .left {
  261. margin-right: 20rpx;
  262. image {
  263. width: 200rpx;
  264. height: 200rpx;
  265. border-radius: 10rpx;
  266. }
  267. }
  268. .content {
  269. .title {
  270. font-size: 28rpx;
  271. line-height: 50rpx;
  272. color: #606266;
  273. }
  274. .type {
  275. margin: 10rpx 0;
  276. font-size: 24rpx;
  277. color: $u-tips-color;
  278. }
  279. .delivery-time {
  280. color: #e5d001;
  281. font-size: 24rpx;
  282. }
  283. .price-row {
  284. display: flex;
  285. justify-content: space-between;
  286. margin: 10rpx 0;
  287. font-size: 26rpx;
  288. .price {
  289. color: #FF0000;
  290. }
  291. .brand{
  292. color: #999999;
  293. background: #F3F3F3;
  294. padding: 0 8rpx;
  295. border-radius: 5rpx;
  296. }
  297. .exchange {
  298. background: #0094FE;
  299. color: #FFFFFF;
  300. padding: 4rpx 16rpx;
  301. line-height: 1.5;
  302. }
  303. }
  304. }
  305. .right {
  306. margin-left: 10rpx;
  307. padding-top: 20rpx;
  308. text-align: right;
  309. .decimal {
  310. font-size: 24rpx;
  311. margin-top: 4rpx;
  312. }
  313. .number {
  314. color: $u-tips-color;
  315. font-size: 24rpx;
  316. }
  317. }
  318. }
  319. .total {
  320. margin-top: 20rpx;
  321. text-align: right;
  322. font-size: 24rpx;
  323. .total-price {
  324. font-size: 32rpx;
  325. }
  326. }
  327. .bottom {
  328. display: flex;
  329. margin-top: 40rpx;
  330. padding: 0 10rpx;
  331. justify-content: space-between;
  332. align-items: center;
  333. .btn {
  334. line-height: 52rpx;
  335. width: 160rpx;
  336. border-radius: 26rpx;
  337. border: 2rpx solid $u-border-color;
  338. font-size: 26rpx;
  339. text-align: center;
  340. color: $u-type-info-dark;
  341. }
  342. .evaluate {
  343. color: $u-type-warning-dark;
  344. border-color: $u-type-warning-dark;
  345. }
  346. }
  347. }
  348. .navigation {
  349. display: flex;
  350. width: 100%;
  351. justify-content: space-between;
  352. margin-top: 100rpx;
  353. border: solid 2rpx #f2f2f2;
  354. background-color: #ffffff;
  355. padding: 16rpx 0;
  356. position: fixed;
  357. bottom: 0;
  358. z-index: 100;
  359. .left {
  360. display: flex;
  361. font-size: 20rpx;
  362. .item {
  363. margin: 0 30rpx;
  364. &.car {
  365. text-align: center;
  366. position: relative;
  367. .car-num {
  368. position: absolute;
  369. top: -10rpx;
  370. right: -10rpx;
  371. }
  372. }
  373. }
  374. }
  375. .right {
  376. display: flex;
  377. font-size: 28rpx;
  378. align-items: center;
  379. .btn {
  380. line-height: 66rpx;
  381. padding: 0 30rpx;
  382. border-radius: 36rpx;
  383. color: #ffffff;
  384. }
  385. .cart {
  386. background-color: #ed3f14;
  387. margin-right: 30rpx;
  388. }
  389. .buy {
  390. margin: 0 16rpx;
  391. background-color: #ff7900;
  392. }
  393. }
  394. }
  395. </style>