determineOrder.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="body">
  3. <view class="header" @click="addressList">
  4. <view class="model" v-if="ProductList.address.name? true :false ">
  5. <view style="font-size: 1rem; font-weight: 550;">{{ProductList.address.area}} {{ProductList.address.addr}} </view>
  6. <view style="margin-top: 2vw;"> <span>{{ProductList.address.name}}</span> <span style="margin-left: 2vw;">{{ProductList.address.tel}}</span> </view>
  7. </view>
  8. <view v-if="ProductList.address.name? false : true " >
  9. <p style="font-size: 0.75rem; color: grey; ">您还没有收获地址哦~</p>
  10. <p
  11. style="width: 20vw; height: 8vw; margin-top: 2vw; text-align: center; line-height: 8vw; border-radius: 5px; color: red; border: 1px solid red; background-color:#fff5f5;">
  12. 添加地址</p>
  13. </view>
  14. </view>
  15. <!--确认订单 -->
  16. <view class="content">
  17. <view class="shopCon">
  18. <p>
  19. <image style="width: 25vw; height: 25vw; border-radius: 8px;" :src="ProductList.product.cover.url"></image>
  20. </p>
  21. <view style="padding-left: 6vw;">
  22. <p style="font-size: 1rem; font-weight: 550;">{{ProductList.product.name}}</p>
  23. <!-- <p style="font-size: 0.75rem; color: grey; margin-top: 2vw;">五香味45g*7</p> -->
  24. <view style=" width: 50vw; display: flex; margin-top: 2vw; ">
  25. <p style="font-size: 1.4rem; font-weight: 550; color: red;">¥{{ProductList.product.price}}</p>
  26. <view style=" width: 40vw; display: flex; margin-left: 8vw;">
  27. <p class="minus_quantity" @click="decrease">-</p>
  28. <input class="input_quantity" type="number" v-model="quantity" @input="handleInput" />
  29. <p class="add_quantity" @click="increase">+</p>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <p class="ProductIntroduction"> <span>商品金额</span> <span style="font-weight: 550;">¥{{ Number(ProductList.product.price*quantity) }}</span> </p>
  35. <!-- <p
  36. class="ProductIntroduction">
  37. <span>优惠金额</span> <span style="color: red; font-weight: 550;">-¥0</span>
  38. </p> -->
  39. <!-- <p
  40. class="ProductIntroduction">
  41. <sapn>恒信豆</sapn> <span style="color: red; font-weight: 550;">-¥0</span></sapn>
  42. </p> -->
  43. <!-- <p
  44. class="ProductIntroduction" >
  45. <span>运费金额</span>
  46. <sapn>¥0</sapn>
  47. </p> -->
  48. <!-- <view
  49. class="ProductIntroduction">
  50. <span>订单备注</span>
  51. <view style="display: flex;">
  52. <p
  53. style=" width: 50vw; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; text-align: center; font-size: 0.8rem; color: grey; ">
  54. {{ProductList.product.notes}}</p>
  55. <p>
  56. <image style="width: 5vw; height: 5vw; " src="../../static/youjian.png" mode=""></image>
  57. </p>
  58. </view>
  59. </view> -->
  60. </view>
  61. <!-- 已选择 -->
  62. <u-toast ref="uToast" />
  63. <view class="foot">
  64. <view style="width: 28vw;">合计: <span style="color: red; font-size: 1.2rem;">¥{{Number(ProductList.product.price*quantity)}}</span> </view>
  65. <view class="button" @click="purchase">下单</view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. quantity: 1,
  74. ProductList:{
  75. product:{price:0}
  76. },
  77. }
  78. },
  79. onLoad(option) {
  80. if(option.storeId){
  81. this.storeId=option.storeId
  82. this.planProductList(option.storeId)
  83. }
  84. },
  85. onShow(){
  86. this.planProductList(this.storeId)
  87. },
  88. methods: {
  89. addressList(){
  90. uni.navigateTo({
  91. url:'/pages/shopStore/Address'
  92. })
  93. },
  94. // 数据信息
  95. planProductList(id){
  96. this.$api.postshopdetial(id,res=>{
  97. if(res.code==0){
  98. this.ProductList=res.data
  99. }
  100. })
  101. },
  102. handleInput(event) {
  103. const value = parseInt(event.target.value);
  104. if (!isNaN(value) && value >= 1) {
  105. this.quantity = value;
  106. } else {
  107. this.quantity = 1;
  108. }
  109. },
  110. increase() {
  111. this.quantity++;
  112. },
  113. decrease() {
  114. if (this.quantity > 1) {
  115. this.quantity--;
  116. }
  117. },
  118. purchase(){
  119. let that=this
  120. if(!that.$db.get('token')){
  121. uni.navigateTo({
  122. url:'/pages/login/login'
  123. })
  124. return
  125. }
  126. that.$api.postPlaceOrder({product:that.ProductList.product.id,customer_address:that.ProductList.address.id,count:that.quantity,price:that.ProductList.product.price},res=>{
  127. if(res.code==0){
  128. uni.requestPayment({
  129. provider:'wxpay',
  130. timeStamp: res.data.timeStamp,
  131. nonceStr: res.data.nonceStr,
  132. package: res.data.package,
  133. signType: res.data.signType,
  134. paySign: res.data.paySign,
  135. success: function(e){
  136. that.successToast('充值成功')
  137. setTimeout(() => {
  138. uni.switchTab({
  139. url:'/pages/shopStore/index'
  140. })
  141. }, 1000)
  142. },
  143. faill:function(e){
  144. console.log(e)
  145. that.errorToast(e)
  146. }
  147. })
  148. }
  149. })
  150. },
  151. successToast(msg) {
  152. this.$refs.uToast.show({
  153. title: msg,
  154. type: 'success',
  155. duration: 1000
  156. })
  157. },
  158. errorToast(msg) {
  159. this.$refs.uToast.show({
  160. title: msg,
  161. type: 'error',
  162. duration: 1000
  163. })
  164. },
  165. }
  166. }
  167. </script>
  168. <style lang="scss" scoped>
  169. .body {
  170. width: 100vw;
  171. height: 100vh;
  172. background-color: #f8f8f8;
  173. box-sizing: border-box;
  174. padding: 0 5vw;
  175. .header {
  176. width: 90vw;
  177. height: 10vh;
  178. background-color: white;
  179. border-radius: 10px;
  180. display: flex;
  181. justify-content: center;
  182. align-items: center;
  183. .model{
  184. width: 90vw;
  185. height: 10vh;
  186. border-radius: 5px;
  187. background-color: white;
  188. box-sizing: border-box;
  189. padding: 2vw;
  190. }
  191. }
  192. .content {
  193. width: 90vw;
  194. height: 30vh;
  195. margin-top: 4vw;
  196. background-color: white;
  197. border-radius: 10px;
  198. .shopCon {
  199. width: 90vw;
  200. height: 20vh;
  201. display: flex;
  202. box-sizing: border-box;
  203. padding: 4vw;
  204. .minus_quantity {
  205. border: 1px solid #f8f8f8;
  206. text-align: center;
  207. width: 20%;
  208. background-color: #f8f8f8;
  209. margin-right: 2vw;
  210. }
  211. .input_quantity {
  212. // border-bottom: 1px solid #74bfe7;
  213. text-align: center;
  214. width: 20%;
  215. height: 8vw;
  216. background-color: #f8f8f8;
  217. }
  218. .add_quantity {
  219. border: 1px solid #f8f8f8;
  220. background-color: #f8f8f8;
  221. text-align: center;
  222. width: 20%;
  223. margin-left: 2vw;
  224. }
  225. }
  226. .ProductIntroduction {
  227. width: 90vw;
  228. margin-top: 2vw;
  229. box-sizing: border-box;
  230. padding: 0 4vw;
  231. display: flex;
  232. justify-content: space-between;
  233. }
  234. }
  235. .foot {
  236. width: 90vw;
  237. height: 20vw;
  238. border-top: 1px solid lightgray;
  239. position: fixed;
  240. bottom: 0;
  241. display: flex;
  242. justify-content: space-between;
  243. align-items: center;
  244. }
  245. .button {
  246. width: 50vw;
  247. height: 12vw;
  248. text-align: center;
  249. line-height: 12vw;
  250. background-color: #f83036;
  251. color: white;
  252. border-radius: 32px;
  253. }
  254. }
  255. </style>