save-order.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="save-order-box iPhone-bottom flex-common-css box-border-box">
  3. <view class="bg-box"></view>
  4. <Nav title='提交订单' bgckgroundBox='transparent'></Nav>
  5. <view class="scroll-view-css box-border-box p-24">
  6. <view class="box-card box-border-box mb-20 bgc-f">
  7. <view class="box-input align-items-center box-border-box p-b-20 mb-20">
  8. <view class="fs-28 fw-600 w158">姓名</view>
  9. <input v-model="fromData.name" type="text" placeholder="请输入姓名">
  10. </view>
  11. <view class="box-input align-items-center box-border-box p-b-20 mb-20">
  12. <view class="fs-28 fw-600 w158">手机号</view>
  13. <input v-model="fromData.phone" type="number" placeholder="请输入手机号">
  14. <view class="fs-28 fc-41ABF5 code-box" @click="getCode()">{{codeText}}{{isCode?'s':''}}</view>
  15. </view>
  16. <view class="box-input align-items-center box-border-box p-b-20 mb-20">
  17. <view class="fs-28 fw-600 w158">验证码</view>
  18. <input v-model="fromData.code" type="number" placeholder="请输入验证码">
  19. </view>
  20. <view class="box-input align-items-center box-border-box p-b-20 mb-20">
  21. <view class="fs-28 fw-600 w158">联系地址</view>
  22. <input v-model="fromData.address" type="text" placeholder="请输入联系地址(选填)">
  23. </view>
  24. </view>
  25. <view class="box-card box-border-box mb-20 bgc-f">
  26. <view class="box-top box-border-box flex-justify-space">
  27. <view class="box-left display-flex">
  28. <image :src="goodsData.cover_img" mode="aspectFill"></image>
  29. <view class="w336 fs-28 fw-400">{{goodsData.title||''}}</view>
  30. </view>
  31. <view class="box-right">
  32. <view class="fs-32 fw-600 text-align-right mb-12">¥19.5</view>
  33. </view>
  34. </view>
  35. <view class="box-buttom text-align-right">
  36. <span class="fs-28 fc-0 fw-400">合计¥</span>
  37. <span class="fs-44 fc-0 fw-b">{{goodsData.deposit||''}}</span>
  38. </view>
  39. </view>
  40. <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  41. <view class="fs-28 fw-600 w158">备注</view>
  42. <input v-model="fromData.note" class="text-align-right" type="text" placeholder="请填写你的备注">
  43. </view>
  44. <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  45. <view class="fs-28 fw-600 w158">支付方式</view>
  46. <view class="wx-box display-flex">
  47. <image src="@/static/img/common/wx-zf.png" mode="scaleToFill"></image>
  48. <view class="fs-28 fw-400 ml-10">微信支付</view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="bottom-box box-border-box p-24">
  53. <view class="flex-justify-space">
  54. <view class="align-items-flex-end box-1">
  55. <span class="fs-28 fc-f fw-600">¥</span>
  56. <span class="fs-44 fc-f fw-600">{{goodsData.deposit||''}}</span>
  57. </view>
  58. <view class="text-align-center box-2 fs-32 fc-f fw-600" @click="toSave()">立即支付</view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import {getCode} from '@/api/common.js';
  65. import {groupPay,groupCreate} from '@/api/groupOrder.js';
  66. import tools from "@/service/tools";
  67. export default {
  68. data(){
  69. return{
  70. isCode:false,
  71. codeText:'获取验证码',
  72. fromData:{
  73. name:'',
  74. id:'',
  75. phone:'',
  76. school_id:'',
  77. code:'',
  78. note:'',
  79. address:'',
  80. },
  81. isAJAX:false,
  82. goodsData:{},
  83. }
  84. },
  85. onLoad(e) {
  86. if(e.goodsData){
  87. let obj = JSON.parse(decodeURIComponent(e.goodsData));
  88. this.goodsData = obj;
  89. this.fromData.id = obj.id;
  90. }
  91. },
  92. methods:{
  93. getCode(){
  94. if (this.isCode) {
  95. return
  96. }
  97. this.isCode = true;
  98. getCode({phone:this.fromData.phone,send_type:'group_order'}).then((res)=>{
  99. if(res.code === 1){
  100. this.codeText = 60;
  101. let timer = setInterval(() => {
  102. this.codeText -= 1;
  103. if (this.codeText <= 0) {
  104. clearInterval(timer);
  105. this.isCode = false;
  106. this.codeText = '获取验证码'
  107. }
  108. }, 1000);
  109. }else{
  110. this.isCode = false;
  111. tools.error('获取验证码失败,请稍后重试')
  112. }
  113. })
  114. },
  115. toSave(){
  116. if (this.isAJAX) {
  117. return
  118. }
  119. this.isAJAX = true;
  120. this.fromData.school_id = uni.getStorageSync('school_id');
  121. groupCreate(this.fromData).then((res)=>{
  122. if(res.code === 1){
  123. groupPay({order_id:res.data.order_id}).then((ret)=>{
  124. if(ret.code === 1){
  125. uni.requestPayment({
  126. provider: "wxpay", //支付类型-固定值
  127. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  128. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  129. package: ret.data.wx_pay.package, // 固定值
  130. signType: ret.data.wx_pay.signType, //固定值
  131. paySign: ret.data.wx_pay.paySign, //签名
  132. success: (ren) => {
  133. tools.success("支付成功");
  134. this.isAJAX = false;
  135. setTimeout(()=>{
  136. uni.switchTab({
  137. url:"/pages/order/index"
  138. })
  139. },1500)
  140. },
  141. fail: (err) =>{
  142. this.isAJAX = false;
  143. tools.error("支付失败");
  144. },
  145. });
  146. }else{
  147. this.isAJAX = false;
  148. tools.error("支付失败");
  149. }
  150. })
  151. }else{
  152. this.isAJAX = false;
  153. tools.error(res.msg);
  154. }
  155. })
  156. },
  157. },
  158. }
  159. </script>
  160. <style scoped lang="scss">
  161. .save-order-box{
  162. position: relative;
  163. .right-only-right-red{
  164. width: 44rpx;
  165. height: 44rpx;
  166. line-height: 40rpx;
  167. border-radius: 12rpx;
  168. border: 1rpx solid #41ABF5;
  169. color: #41ABF5;
  170. }
  171. .right-only-right-add{
  172. width: 44rpx;
  173. height: 44rpx;
  174. line-height: 40rpx;
  175. background: linear-gradient( 117deg, #57CAFF 0%, #41ABF5 100%);
  176. border-radius: 12rpx;
  177. }
  178. .right-only-right-2{
  179. min-width: 50rpx;
  180. }
  181. .bg-box{
  182. width: 100%;
  183. height: 448rpx;
  184. filter: blur(80rpx);
  185. background: linear-gradient(to right,rgba(176, 252, 250, 0.6),rgba(249,246,224,0.87),rgba(249,246,224,0.87));
  186. position: absolute;
  187. top: 0;
  188. left: 0;
  189. z-index: -1;
  190. }
  191. .bottom-box{
  192. background-color: #fff;
  193. .box-1{
  194. flex: 1;
  195. height: 100rpx;
  196. background: #333;
  197. border-radius: 200rpx 0rpx 0rpx 200rpx;
  198. box-sizing: border-box;
  199. padding-left: 32rpx;
  200. padding-bottom: 20rpx;
  201. }
  202. .box-2{
  203. width: 200rpx;
  204. height: 100rpx;
  205. line-height: 100rpx;
  206. background: #41ABF5;
  207. border-radius: 0rpx 200rpx 200rpx 0rpx;
  208. text-align: center;
  209. }
  210. }
  211. .box-card{
  212. width: 100%;
  213. min-height: 88rpx;
  214. border-radius: 20rpx;
  215. padding: 24rpx 24rpx 0 24rpx;
  216. .box-top{
  217. padding-bottom: 24rpx;
  218. border-bottom: 2rpx solid #F9F9F9;
  219. margin-bottom: 24rpx;
  220. .box-left{
  221. image{
  222. width: 108rpx;
  223. height: 108rpx;
  224. border-radius: 8rpx;
  225. margin-right: 16rpx;
  226. }
  227. .w336{
  228. width: 336rpx;
  229. }
  230. }
  231. }
  232. .box-buttom{
  233. padding-bottom: 24rpx;
  234. }
  235. }
  236. .box-input{
  237. border-bottom: 2rpx solid #F9F9F9;
  238. position: relative;
  239. .w158{
  240. width: 158rpx;
  241. }
  242. input{
  243. font-size: 28rpx;
  244. }
  245. .code-box{
  246. position: absolute;
  247. right: 0;
  248. top: 0;
  249. }
  250. }
  251. .wx-box{
  252. image{
  253. width: 40rpx;
  254. height: 40rpx;
  255. }
  256. }
  257. }
  258. </style>