confirmOrder.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <s-layout style="margin-top: 40px;">
  3. <view style="background-color: #fff;">
  4. <!-- <view class="cu-bar bg-white ">
  5. <view class="action">
  6. <text class="cuIcon-titles text-orange"></text> 配送方式
  7. </view>
  8. </view> -->
  9. <!-- <scroll-view scroll-x class="bg-white nav">
  10. <view class="flex text-center">
  11. <view class="cu-item flex-sub" :class="TabCur=='1'?'text-orange cur':''" @tap="tabSelect" :data-id="1">
  12. 配送
  13. </view>
  14. <view class="cu-item flex-sub" :class="TabCur=='2'?'text-orange cur':''" @tap="tabSelect" :data-id="2">
  15. 到店
  16. </view>
  17. </view>
  18. </scroll-view> -->
  19. <uni-datetime-picker type="datetime" v-model="datetimesingle" placeholder="预计时间" />
  20. </view>
  21. <!-- <view style="background-color: #fff;">
  22. <view class="cu-bar bg-white ">
  23. <view class="action">
  24. <text class="cuIcon-titles text-orange"></text> 收货地址
  25. </view>
  26. </view>
  27. <view style="width: 100%;padding:10px;" class="ss-flex">
  28. <view style="width: 40%;font-size: 20px;">{{ addressList.name }}</view>
  29. <view style="width: 50%;font-size: 20px;">{{ addressList.phone }}</view>
  30. </view>
  31. <view style="width: 100%;padding:10px;">{{ addressList.address }}</view>
  32. <button style="margin: 20px;" type="primary"
  33. @tap="sheep.$router.go('/pages/user/address/edit')">修改地址</button>
  34. </view> -->
  35. <view style="height: 90vh;">
  36. <view class="cu-bar bg-white ">
  37. <view class="action">
  38. <text class="cuIcon-titles text-orange"></text> 购物车
  39. </view>
  40. </view>
  41. <view style="height: 80vh;overflow-y: auto;background-color: #fff;">
  42. <view v-for="(i, j) in nowCartList" :key="j" class="minmi" style="width: 100vw;">
  43. <image class="imgPic" :src="i.url" mode=""></image>
  44. <view class="rightContainer">
  45. <view class="foodName">
  46. {{ i.name }}
  47. </view>
  48. <view class="foodPrice">
  49. <view class="priceflex">
  50. <text class="zero">¥</text>
  51. {{ i.priceVisable }}
  52. </view>
  53. <view class="shopCar iconfont-themeColor-write" v-show="i.num == 0" @tap="addcart(i)">
  54. <text class="lg text-white cuIcon-add"></text>
  55. </view>
  56. <view class="" v-if="i.num > 0">
  57. <!-- <text class="lg text-white cuIcon-minus" @tap="addcart(i)" ></text> -->
  58. <!-- <uni-number-box :min="0" :max="100" :step="1" v-model="i.num" @tap="chengeCart(i)" /> -->
  59. <text>{{ i.num }}</text>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <button class="bg-red submit" @click="handleOk()">立即支付</button>
  66. </view>
  67. </s-layout>
  68. </template>
  69. <script setup>
  70. import sheep from '@/sheep';
  71. import { onLaunch, onShow, onError } from '@dcloudio/uni-app';
  72. import { computed, reactive, ref } from 'vue';
  73. import goodsApi from '@/sheep/api/restaurant/goods'
  74. const cart = sheep.$store('cart');
  75. const TabCur = ref(1)
  76. const datetimesingle = ref('')
  77. const nowCartList= computed(() => cart.list)
  78. const addressList = computed(() => {
  79. let addressList = sheep.$store('user').addressList
  80. console.log('restaurant', addressList)
  81. return addressList
  82. })
  83. const handleOk= async () =>{
  84. if(datetimesingle.value ==''){
  85. sheep.$helper.toast('请选择用餐时间')
  86. return
  87. }
  88. let pamser = {
  89. name: addressList.value.name,
  90. phone: addressList.value.phone,
  91. address: addressList.value.address,
  92. useTime:datetimesingle.value,
  93. type: TabCur.value,
  94. goodsList:nowCartList.value,
  95. openid :uni.getStorageSync('openid')
  96. }
  97. const formData = {
  98. ...pamser
  99. }
  100. console.log('pamser',formData)
  101. await goodsApi.createOrder(formData).then(res => {
  102. console.log(res)
  103. })
  104. }
  105. const tabSelect= (e) =>{
  106. console.log(e.currentTarget.dataset.id)
  107. TabCur.value = e.currentTarget.dataset.id;
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .title{
  112. width: 99%;
  113. text-align: left;
  114. padding-left: 10px;
  115. border-left: 5px solid red;
  116. font-size: 18px;
  117. margin-left: 20px;
  118. margin-top: 10px;
  119. font-weight: 800;
  120. }
  121. .active {
  122. font-size: 30upx;
  123. color: #F9BE3E;
  124. }
  125. .active2 {
  126. font-size: 30upx;
  127. }
  128. .min {
  129. display: flex;
  130. flex-direction: row;
  131. justify-content: space-around;
  132. flex-wrap: wrap;
  133. // margin: 20px 0;
  134. background-color: white;
  135. padding-bottom: 20px;
  136. }
  137. .minmi {
  138. display: flex;
  139. width: 592upx;
  140. margin-left: 25upx;
  141. padding-top: 51upx;
  142. .imgPic {
  143. width: 208upx;
  144. height: 167upx;
  145. border-radius: 10upx;
  146. margin-left: 20upx;
  147. }
  148. .rightContainer {
  149. display: flex;
  150. flex-direction: column;
  151. height: 167upx;
  152. box-sizing: border-box;
  153. justify-content: space-between;
  154. align-items: flex-start;
  155. padding-left: 18upx;
  156. padding-right: 18upx;
  157. padding-top: 18upx;
  158. // padding-bottom: 18upx;
  159. flex: 1;
  160. .foodName {
  161. font-weight: 700;
  162. font-size: 25upx;
  163. }
  164. .foodPrice {
  165. display: flex;
  166. justify-content: space-between;
  167. width: 375upx;
  168. color: #F9BE3E;
  169. .priceflex {
  170. display: flex;
  171. align-items: center;
  172. .zero {
  173. font-size: 15upx;
  174. }
  175. }
  176. .shopCar {
  177. background-color: #F9BE3E;
  178. border-radius: 45upx;
  179. width: 112upx;
  180. height: 45upx;
  181. font-size: 25upx;
  182. text-align: center;
  183. line-height: 46upx;
  184. }
  185. }
  186. }
  187. }
  188. .aside-main {
  189. width: 100%;
  190. display: flex;
  191. flex-direction: row;
  192. justify-content: space-between;
  193. box-sizing: border-box;
  194. }
  195. .scroll-Y1 {
  196. flex: 1;
  197. box-sizing: border-box;
  198. }
  199. .scroll-Y1 view {
  200. text-align: center;
  201. padding-top: 33upx;
  202. // padding-bottom: 33upx;
  203. }
  204. .scroll-Y2 {
  205. flex: 3;
  206. box-sizing: border-box;
  207. // padding-bottom: 170upx;
  208. }
  209. .scroll-Y2 view {
  210. text-align: center;
  211. /* margin:20upx; */
  212. }
  213. .icon {
  214. width: 50upx;
  215. height: 50upx;
  216. margin-top: 10upx;
  217. }
  218. .icon1 {
  219. width: 30upx;
  220. height: 30upx;
  221. position: absolute;
  222. top: 15upx;
  223. left: 10upx;
  224. }
  225. .btn {
  226. width: 140upx;
  227. height: 60upx;
  228. line-height: 60upx;
  229. margin: 0;
  230. padding: 0;
  231. font-size: 30upx;
  232. }
  233. .serch {
  234. height: 60upx;
  235. flex: 2;
  236. margin-left: 20upx;
  237. margin-right: 20upx;
  238. box-sizing: border-box;
  239. border: solid 1upx #ccc;
  240. border-radius: 10upx;
  241. position: relative;
  242. }
  243. .serch input {
  244. height: 60upx;
  245. margin-left: 60upx;
  246. }
  247. </style>