save-order.vue 7.5 KB

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