submitOrder.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="w-full">
  3. <send-type @sendTypeChange="sendTypeChange" />
  4. <view class="gap"></view>
  5. <!-- <view class="address">
  6. <u-cell-group>
  7. <u-cell title="添加收货地址" :border="false" url='' isLink>
  8. <u-icon slot="icon" size="24" name="plus"></u-icon>
  9. </u-cell>
  10. </u-cell-group>
  11. </view> -->
  12. <view class="padding-sm dflex-b bg-main" @click="show = true">
  13. <view class="dflex">
  14. <!-- <view class="addr-label">配送至</view> -->
  15. <view class="w-full dflex-wrap-w send-label">
  16. 取餐时间
  17. </view>
  18. </view>
  19. <u-icon slot="icon" size="20" name="arrow-right" :label="value" labelPos="left"></u-icon>
  20. <!-- <view class="iconfont iconjiantou-01 fs-sm"></view> -->
  21. </view>
  22. <u-datetime-picker :show="show" v-model="value" mode="time" @confirm="onConfirm"
  23. @cancel="onCancel"></u-datetime-picker>
  24. <view class="gap"></view>
  25. <view class="padding-sm dflex-b bg-main">
  26. <view class="dflex">
  27. <!-- <view class="addr-label">配送至</view> -->
  28. <view class="w-full dflex-wrap-w send-label">
  29. 取餐方式
  30. </view>
  31. </view>
  32. <view>
  33. <uni-data-checkbox v-model="val" :localdata="list" @change="radioChange"
  34. selectedColor="#F54319"></uni-data-checkbox>
  35. <!-- <radio style="margin: 0 10px; transform: scale(0.85)" value="r1" :checked="typePicking" color="#ff0000" class="radio">店内用餐
  36. </radio >
  37. <radio style="transform: scale(0.85)" value="r1" :checked="typePickings" color="#ff0000" class="radio">打包带走
  38. </radio> -->
  39. </view>
  40. <!-- <view class="iconfont iconjiantou-01 fs-sm"></view> -->
  41. </view>
  42. <view class="gap"></view>
  43. <view class="goods-order-list w-full padding-lr-sm">
  44. <view class="shop dflex-b ">
  45. <view class="shop-check">
  46. <text class="shop-name">{{cList.name}}</text>
  47. </view>
  48. </view>
  49. <view class="goods-cart w-full">
  50. <view class="goods-cont padding-tb" v-for="(item, index) in data.carlist" :key="index">
  51. <my-goods :item="item">
  52. <view class="good-num">×{{item.quantity}}</view>
  53. </my-goods>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 金额明细 -->
  58. <view class="gap"></view>
  59. <view class="bg-main">
  60. <view class="dflex-b padding-lr padding-tb-sm">
  61. <view class="flex1">总金额</view>
  62. <view class=""><text style="font-size: 24rpx;">¥</text>{{data.total}}</view>
  63. </view>
  64. <!-- <view class="dflex-b padding-lr padding-tb-sm">
  65. <view class="flex1">运费 (总重:4.960 kg )</view>
  66. <view class="ft-base">¥10.00</view>
  67. </view>
  68. <view class="dflex-b padding-lr padding-tb-sm">
  69. <view class="margin-right-xl">备注</view>
  70. <input class="flex1 padding-sm" type="text" v-model="order_desc" placeholder="请填写买家备注"
  71. placeholder-class="placeholder" />
  72. </view> -->
  73. </view>
  74. <view class="gap"></view>
  75. <my-gap :height="130" />
  76. <view class="submit-bar padding-sm dflex-b">
  77. <view class="submit-btn dflex-c background-gradient" @click="toBuy">立即下单</view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. export default {
  83. data() {
  84. return {
  85. data: [],
  86. show: false,
  87. value: '',
  88. cList: {},
  89. val: null,
  90. vals: null,
  91. list: [{
  92. text: "店内用餐",
  93. value: 'A'
  94. },
  95. {
  96. text: "打包带走",
  97. value: 'B'
  98. }
  99. ]
  100. }
  101. },
  102. onLoad(option) {
  103. const e = uni.getStorageSync('carl')
  104. this.cList = e
  105. console.log('233333333333333', e)
  106. // 解码 URL 编码的字符串
  107. var dataString = decodeURIComponent(option.data);
  108. // 尝试将字符串转换为 JSON 对象
  109. var data = JSON.parse(dataString);
  110. this.data = data
  111. // 打印解码后的数据
  112. console.log('eeeeeeeeeeeee============data', data);
  113. },
  114. methods: {
  115. sendTypeChange(v) {},
  116. radioChange(v) {
  117. console.log('2=================', v)
  118. console.log('2=================22222', this.val)
  119. },
  120. onConfirm(v) {
  121. console.log('vvvvvvvvvvvvvvv', v)
  122. this.value = v.value
  123. this.show = false
  124. },
  125. onCancel() {
  126. this.show = false
  127. },
  128. toBuy() {
  129. console.log('this.val', this.val)
  130. if (this.value == '') {
  131. uni.showToast({
  132. title: '请选择取餐时间',
  133. icon: 'error',
  134. duration: 1000
  135. })
  136. return
  137. }
  138. if (this.val == '' || this.val == null) {
  139. uni.showToast({
  140. title: '请选择取餐方式',
  141. icon: 'error',
  142. duration: 1000
  143. })
  144. return
  145. }
  146. const userName = uni.getStorageSync('userName');
  147. const itemListArray = this.data.carlist.map(item => ({
  148. skuId: item.skuId,
  149. isGift: false, // 假设所有商品都不是礼物
  150. basePrice: item.basePrice,
  151. price: item.price,
  152. quantity: item.quantity,
  153. sellerType: 'C', // 假设所有商品卖家类型都是 'C'
  154. isFenxiao: false // 假设所有商品都不是分销商品
  155. }))
  156. const params = {
  157. orderType: 'waimai,cod',
  158. isCod: true,
  159. shippingType: 'SELF_PICKUP',
  160. storeId: this.cList.id,
  161. storeName: this.cList.name,
  162. arriveCutTime: this.value,
  163. sellerNick: this.cList.name,
  164. buyerNick: userName,
  165. itemList: itemListArray,
  166. pickupInfo: {
  167. pickupType: this.val,
  168. isVerify: false
  169. }
  170. }
  171. console.log('params', params);
  172. // uni.navigateTo({
  173. // url: `/pages/order/orderPaid/orderPaid`
  174. // })
  175. this.$request('post', `/order/retailOrder`, params, true).then(response => {
  176. // 请求成功
  177. console.log('response', response)
  178. if (response.code == 200) {
  179. const ids = this.data.carlist.map(car => car.id);
  180. this.$request('delete', `/front/shoppingCart/${ids}`)
  181. console.log('response.data', response.data)
  182. uni.navigateTo({
  183. url: `/pages/order/orderPaid/orderPaid?id=${response.data}`
  184. })
  185. } else if (response.code == 500) {
  186. uni.showToast({
  187. title: response.msg,
  188. icon: 'error',
  189. duration: 2000
  190. });
  191. }
  192. }).catch(error => {
  193. // 请求失败
  194. console.error('请求失败:', error);
  195. })
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .addr-label {
  202. padding: 6upx 0;
  203. border-radius: 3px;
  204. background-color: #F6390D;
  205. color: #fff;
  206. width: 120upx;
  207. text-align: center;
  208. flex-shrink: 0;
  209. margin-right: 14upx;
  210. }
  211. .order-spec {
  212. padding-bottom: 10upx;
  213. }
  214. .shop {
  215. padding-top: 20upx;
  216. }
  217. .goods-num {
  218. font-size: 16px;
  219. padding-left: 20upx;
  220. }
  221. .goods-cont {
  222. width: 100%;
  223. box-sizing: border-box;
  224. }
  225. .total-goods {
  226. font-size: 12px;
  227. color: #999;
  228. }
  229. .submit-bar {
  230. height: 130rpx;
  231. width: 100%;
  232. background-color: #FFF;
  233. position: fixed;
  234. left: 0;
  235. bottom: 0;
  236. box-shadow: 0px -4px 16px 0px rgba(0, 0, 0, 0.15);
  237. z-index: 10;
  238. .submit-btn {
  239. background-color: #0581FE;
  240. height: 100%;
  241. width: 100%;
  242. color: #FFF;
  243. font-size: 14px;
  244. // font-weight: 700;
  245. border-radius: 35upx;
  246. }
  247. }
  248. .good-num {
  249. font-size: 12px;
  250. padding-top: 65rpx;
  251. }
  252. .send-label {
  253. font-size: 14px;
  254. font-weight: 700;
  255. }
  256. </style>