天波h5前端应用
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

339 行
12KB

  1. <!--
  2. * @Date: 2022-01-19 16:53:16
  3. * @LastEditors: JinxChen
  4. * @LastEditTime: 2022-04-13 14:26:06
  5. * @FilePath: \AntpayFrontEnd\src\views\alipay-dealers\AlipayFormDealers.vue
  6. * @description: 表单信息录入
  7. -->
  8. <template>
  9. <div class="form-container">
  10. <!-- 头部 -->
  11. <div class="form-header pos-flex-cen">
  12. <van-image radius="10" :src="goodsData.imgPath" @click="onPreview"></van-image>
  13. </div>
  14. <!-- 中部表单 -->
  15. <div class="form-body pos-flex-cen">
  16. <div class="tips">
  17. <span class="font-red font-16"><van-icon name="warning" size="15" color="#1989fa" />友情提醒:</span>此处填写的联系电话,必须与“随手精灵0元购”下单时填写的电话为同一个。
  18. </div>
  19. <van-form>
  20. <van-field
  21. v-model="form.schoolName"
  22. v-if="false"
  23. name="学校名称"
  24. label="学校名称:"
  25. required
  26. maxlength="50"
  27. left-icon="wap-home-o"
  28. clearable
  29. :rules="[{ required: true, message: '请填写学校名称' }]"
  30. />
  31. <van-field
  32. v-model="form.className"
  33. v-if="false"
  34. name="年级班级"
  35. label="年级班级:"
  36. required
  37. maxlength="20"
  38. left-icon="description"
  39. clearable
  40. :rules="[{ required: true, message: '请填写年级班级' }]"
  41. />
  42. <van-field
  43. v-model="form.studentName"
  44. v-if="false"
  45. name="学生姓名"
  46. label="学生姓名:"
  47. required
  48. maxlength="10"
  49. left-icon="manager-o"
  50. clearable
  51. :rules="[{ required: true, message: '请填写学生姓名' }]"
  52. />
  53. <van-field
  54. v-model="form.parentName"
  55. v-if="false"
  56. name="家长姓名"
  57. label="家长姓名:"
  58. required
  59. maxlength="10"
  60. left-icon="friends-o"
  61. clearable
  62. :rules="[{ required: true, message: '请填写家长姓名' }]"
  63. />
  64. <van-field
  65. v-model="form.contactsManName"
  66. v-if="true"
  67. name="联系人"
  68. label="联系人:"
  69. required
  70. maxlength="10"
  71. left-icon="contact"
  72. clearable
  73. :rules="[{ required: true, message: '请填写联系人' }]"
  74. />
  75. <van-field
  76. v-model="form.contactsTelephone"
  77. v-if="true"
  78. name="联系电话"
  79. label="联系电话:"
  80. required
  81. maxlength="11"
  82. left-icon="phone-o"
  83. clearable
  84. :rules="[{ required: true, message: '请填写联系电话' }]"
  85. />
  86. <van-field
  87. v-model="form.familyNumber"
  88. v-if="false"
  89. type="textarea"
  90. :autosize="true"
  91. name="亲情号码"
  92. label="亲情号码:"
  93. placeholder="每个亲情号码用 , 隔开,最多可支持4个"
  94. required
  95. maxlength="50"
  96. left-icon="phone-circle-o"
  97. clearable
  98. :rules="[{ required: true, message: '请填写亲情号码' }]"
  99. />
  100. <van-field
  101. v-model="form.studentCard"
  102. v-if="false"
  103. name="学生身份证"
  104. label="学生身份证:"
  105. placeholder="学生身份证"
  106. required
  107. maxlength="20"
  108. left-icon="idcard"
  109. clearable
  110. :rules="[{ required: true, message: '请填写学生身份证' }]"
  111. />
  112. <van-field
  113. v-model="form.receivingAddress"
  114. v-if="false"
  115. name="收货地址"
  116. label="收货地址:"
  117. type="textarea"
  118. :autosize="{ maxHeight: 100, minHeight: 25 }"
  119. required
  120. maxlength="50"
  121. left-icon="location-o"
  122. clearable
  123. :rules="[{ required: true, message: '请填写收货地址' }]"
  124. >
  125. </van-field>
  126. <van-cell :center="true" v-if="false">
  127. <div class="switch-address ">
  128. <div class="left"><van-switch v-model="checked" /></div>
  129. <div class="rigth"><van-icon name="warning" color="#1989fa"/><span>点击切换到商家配送</span></div>
  130. </div>
  131. </van-cell>
  132. </van-form>
  133. </div>
  134. <!-- 底部按钮 -->
  135. <div class="form-footer">
  136. <div class="know-tips">
  137. <p class="font-red font-big"><van-icon name="warning" size="15" color="#1989fa" /><span class="font-16">友情提醒:</span></p>
  138. <p>每月从您的支付宝余额扣除{{(goodsData.price / goodsData.count).toFixed(2)}}元</p>
  139. <p>即将从您的余额扣除{{goodsData.price}}元</p>
  140. </div>
  141. <van-button :disabled="!canSubmit" block @click="onSubmit"><span class="font-white">{{submitText}}</span></van-button>
  142. </div>
  143. </div>
  144. </template>
  145. <script>
  146. import { APIAlipay } from "../../api/alipay";
  147. /* import { IMAGE_URL } from '../../config/models'; */
  148. export default {
  149. name:'alipay-form',
  150. data(){
  151. return {
  152. goodsData: {
  153. imgPath: '' || require('@/assets/img/dealers_form_banner.jpg'),
  154. price: JSON.parse(this.$route.query.price) || '',
  155. count: JSON.parse(this.$route.query.count) || 24,
  156. isAmountShow: '',
  157. mainTitle: '',
  158. title: '4G电子学生证资费套餐开通服务协议',
  159. }, //接收从首页传过来的数据
  160. form: {
  161. studentName: '',
  162. parentName: '',
  163. schoolName: '',
  164. className: '',
  165. studentCard: '',
  166. receivingAddress: '到店自提',
  167. contactsManName: '',
  168. contactsTelephone: '',
  169. }, //输入的表单数据
  170. alipayForm: '', //接收支付宝接口返回的表单
  171. submitText: '办理支付宝分期业务', //submit标题
  172. Imgshow: false, //相片预览
  173. images: [
  174. 'https://img01.yzcdn.cn/vant/apple-1.jpg',
  175. ], //预览图片数组
  176. canSubmit: true, //是否可以提交, 默认false
  177. checked: false, //地址选择开关
  178. }
  179. },
  180. created() {
  181. this.getGoodsDetails();
  182. },
  183. methods: {
  184. // 根据商品编号获取商品详情
  185. getGoodsDetails() {
  186. APIAlipay.getGoodsDetails(this.$store.getters.goodsNo, this.$store.getters.userId)
  187. .then(res => {
  188. if(res.data.code === 20000) {
  189. let good = res.data.data.goods;
  190. console.log("good", good);
  191. // 图片路径
  192. /* this.goodsData.imgPath = IMAGE_URL[ process.env.NODE_ENV ] + good.goodsImg; */
  193. // 价格
  194. // 是否是老用户
  195. this.isOld = good.descriptionText === '' ? true : false;
  196. // 商品名称
  197. this.goodsData.mainTitle = good.mainTitle;
  198. // 是否显示金额总数, todo 后期需从接口获取
  199. /* this.goodsData.isAmountShow = JSON.parse(this.$route.query.isAmountShow); */
  200. }
  201. })
  202. },
  203. // 办理支付宝分期业务表单校验通过后
  204. onSubmit() {
  205. let reg = /^1[3456789]\d{9}$/; //手机号码正则验证
  206. if(!reg.test(this.form.phoneNumber)) {
  207. this.$notify({
  208. message: '请输入正确的手机号码',
  209. type: 'warning',
  210. duration: 1500
  211. })
  212. } else {
  213. let reqBody = {
  214. username: this.form.userName,
  215. deviceImei: this.form.deviceImei === '' ? '123' : this.form.deviceImei,
  216. schoolName: this.form.schoolName,
  217. className: this.form.className,
  218. phoneNumber: this.form.phoneNumber,
  219. periodizationNum: Number(this.goodsData.count),
  220. goodsNo: this.$store.getters.goodsNo,
  221. alipayStateType: Number(this.goodsData.payType),
  222. userId: this.$store.getters.userId,
  223. }
  224. APIAlipay.getAlipayForm(reqBody)
  225. .then(res => {
  226. this.alipayForm = res.data;
  227. this.$store.commit('price', Number(this.goodsData.price));
  228. this.$store.commit('count', Number(this.goodsData.count));
  229. // 跳转到一个中转页 form,再通过这个中转页来调起支付宝的收银台
  230. this.$router.push({path: 'redirect', query: {alipayForm: this.alipayForm}});
  231. })
  232. .catch(error => {
  233. console.log(error);
  234. })
  235. }
  236. },
  237. // 表单不通过时
  238. onFailed() {
  239. console.log("表单输入不完整!");
  240. },
  241. // 图片预览
  242. onChange() {
  243. },
  244. // 点击图片预览大图
  245. onPreview() {
  246. this.Imgshow = true;
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="scss">
  252. .van-form {
  253. overflow: scroll;
  254. border-radius: 10px;
  255. }
  256. </style>
  257. <style scoped lang="scss">
  258. .form-container {
  259. height: 100vh;
  260. width: 100vw;
  261. display: flex;
  262. flex-direction: column;
  263. overflow: hidden;
  264. padding: 10px;
  265. .form-header {
  266. height: 45vh;
  267. width: 100%;
  268. background-color: sandybrown;
  269. border-top-left-radius: 10px;
  270. border-top-right-radius: 10px;
  271. box-shadow: rgb(38, 57, 77) 0px 10px 20px -10px;
  272. background: linear-gradient(to bottom right, rgb(253, 198, 232), 60%, rgba(162, 94, 207, 0.952));
  273. .van-image {
  274. flex: 1;
  275. width: 100%;
  276. }
  277. }
  278. .form-body {
  279. flex: 1;
  280. width: 100%;
  281. overflow: scroll;
  282. margin: 20px 0 10px 0;
  283. /* box-shadow: rgb(38, 57, 77) 0px 10px 20px -10px; */
  284. border-bottom-left-radius: 10px;
  285. border-bottom-right-radius: 10px;
  286. /* background: linear-gradient(to bottom right, rgb(154, 213, 252), 40%, rgb(96, 141, 238)); */
  287. /* background: linear-gradient(to bottom right, rgb(253, 198, 232), 40%, rgb(165, 108, 211)); */
  288. .tips {
  289. height: 60px;
  290. width: 100%;
  291. padding: 0 20px 20px 20px;
  292. line-height: 20px;
  293. text-align: left;
  294. }
  295. .switch-address {
  296. display: flex;
  297. justify-content: flex-start;
  298. align-items: center;
  299. .rigth {
  300. padding-left: 10px;
  301. }
  302. }
  303. }
  304. .form-footer {
  305. height: 20vh;
  306. width: 100%;
  307. padding: 0 10px;
  308. display: flex;
  309. justify-content: center;
  310. align-items:flex-start;
  311. flex-direction: column;
  312. .know-tips {
  313. width: 100%;
  314. display: flex;
  315. justify-content: flex-start;
  316. align-items: flex-start;
  317. flex-direction: column;
  318. margin-bottom: 10px;
  319. border-radius: 10px;
  320. p {
  321. padding: 5px;
  322. }
  323. }
  324. .van-button {
  325. background: linear-gradient(to bottom right, rgb(154, 213, 252), 40%, rgb(96, 141, 238));
  326. }
  327. }
  328. }
  329. </style>