zhifutanchuan.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view :style="{ top: 0 }" class="z-popup">
  3. <view class="anniukuang" v-if="
  4. infoSync.miniProgram.appId == 'wxb80d6a6523463b70' ? !showYSF : true
  5. ">
  6. <button class="btn" @click="WeiXinPay">
  7. <uni-icons type="weixin" size="30" style="margin-right: 20rpx"></uni-icons>
  8. 微信支付
  9. </button>
  10. </view>
  11. <view class="anniukuang" v-if="showYSF">
  12. <button class="btn" @click="YunFlashPay">
  13. <uni-icons type="cloud-upload" size="30" style="margin-right: 20rpx"></uni-icons>
  14. 云闪付
  15. </button>
  16. </view>
  17. <neil-modal v-if="isShow" :show="isShow" title="以旧换新参与人信息" @cancel="fail" @confirm="success">
  18. <view style="min-height: 90upx; padding: 32upx 24upx">
  19. <view>应'政府以旧换新补贴'政策要求发票抬头需与享受以旧换新者(领券人)实名信息完全一致,请务必填写准确!若不一致,后续有补贴失败追回风险。</view>
  20. <view style="height: 20rpx"></view>
  21. <view class="uni-form-item uni-column">
  22. <view class="title">用户姓名</view>
  23. <input class="uni-input" v-model="buyerName" :placeholder="isShow ? '请输入' : ''" />
  24. </view>
  25. <view class="uni-form-item uni-column">
  26. <view class="title">身份证</view>
  27. <input class="uni-input" v-model="buyerIdCard" :placeholder="isShow ? '请输入' : ''" />
  28. </view>
  29. </view>
  30. </neil-modal>
  31. </view>
  32. </template>
  33. <script>
  34. import neilModal from '@/components/neil-modal/neil-modal.vue';
  35. export default {
  36. props: {
  37. orderInfo: {
  38. type: Object,
  39. default: () => ({}),
  40. },
  41. },
  42. components: {
  43. neilModal,
  44. },
  45. computed: {
  46. showYSF() {
  47. return (
  48. this.orderInfo.isRecordBuyer &&
  49. ((this.orderInfo.goods &&
  50. !this.orderInfo.goods.find((item) => item.num > 1)) ||
  51. (this.orderInfo.orderDetails &&
  52. !this.orderInfo.orderDetails.find((item) => item.num > 1)))
  53. );
  54. },
  55. },
  56. data() {
  57. return {
  58. infoSync: uni.getAccountInfoSync(),
  59. isShow: false,
  60. buyerName: '',
  61. buyerIdCard: '',
  62. };
  63. },
  64. methods: {
  65. WeiXinPay() {
  66. this.$emit('PAY_TYPE_STR', {
  67. payType: '微信支付',
  68. wechatPay: true,
  69. });
  70. },
  71. YunFlashPay() {
  72. if (this.orderInfo.isRecordBuyer) {
  73. this.isShow = true;
  74. } else {
  75. this.$emit('PAY_TYPE_STR', {
  76. payType: '云闪付',
  77. wechatPay: false,
  78. });
  79. }
  80. },
  81. isIdCard(idCard) {
  82. // 15位和18位身份证号码的正则表达式
  83. var regIdCard =
  84. /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
  85. // 如果通过该验证,说明身份证格式正确,但准确性还需计算
  86. if (regIdCard.test(idCard)) {
  87. if (idCard.length == 18) {
  88. var idCardWi = new Array(
  89. 7,
  90. 9,
  91. 10,
  92. 5,
  93. 8,
  94. 4,
  95. 2,
  96. 1,
  97. 6,
  98. 3,
  99. 7,
  100. 9,
  101. 10,
  102. 5,
  103. 8,
  104. 4,
  105. 2
  106. ); // 将前17位加权因子保存在数组里
  107. var idCardY = new Array(1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2); // 这是除以11后,可能产生的11位余数、验证码,也保存成数组
  108. var idCardWiSum = 0; // 用来保存前17位各自乖以加权因子后的总和
  109. for (var i = 0; i < 17; i++) {
  110. idCardWiSum += idCard.substring(i, i + 1) * idCardWi[i];
  111. }
  112. var idCardMod = idCardWiSum % 11; // 计算出校验码所在数组的位置
  113. var idCardLast = idCard.substring(17); // 得到最后一位身份证号码
  114. // 如果等于2,则说明校验码是10,身份证号码最后一位应该是X
  115. if (idCardMod == 2) {
  116. if (idCardLast == 'X' || idCardLast == 'x') {
  117. //alert("恭喜通过验证啦!");
  118. return true;
  119. } else {
  120. //alert("身份证号码错误!");
  121. return false;
  122. }
  123. } else {
  124. // 用计算出的验证码与最后一位身份证号码匹配,如果一致,说明通过,否则是无效的身份证号码
  125. if (idCardLast == idCardY[idCardMod]) {
  126. //alert("恭喜通过验证啦!");
  127. return true;
  128. } else {
  129. //alert("身份证号码错误!");
  130. return false;
  131. }
  132. }
  133. } else {
  134. return true;
  135. }
  136. } else {
  137. //alert("身份证格式不正确!");
  138. return false;
  139. }
  140. },
  141. checkChinese(val) {
  142. return val.charCodeAt() > 255 ? true : false;
  143. },
  144. success() {
  145. this.isShow = false;
  146. if (!this.buyerName || !this.buyerIdCard) {
  147. this.$toast('用户姓名与身份证必须填写!');
  148. return;
  149. }
  150. if (!(this.buyerName.length >= 2 && this.checkChinese(this.buyerName))) {
  151. this.$toast('姓名必须至少两个字并且为中文!');
  152. return;
  153. }
  154. if (!this.isIdCard(this.buyerIdCard)) {
  155. this.$toast('身份证不符合规格!');
  156. return;
  157. }
  158. this.$emit('PAY_TYPE_STR', {
  159. payType: '云闪付',
  160. wechatPay: false,
  161. buyerName: this.buyerName,
  162. buyerIdCard: this.buyerIdCard,
  163. });
  164. },
  165. fail() {
  166. this.isShow = false;
  167. },
  168. },
  169. };
  170. </script>
  171. <style scoped lang="scss">
  172. .btn {
  173. width: 100%;
  174. font-size: 36rpx;
  175. display: flex;
  176. flex-direction: row;
  177. align-items: center;
  178. justify-content: center;
  179. box-sizing: border-box;
  180. }
  181. .z-popup {
  182. position: fixed;
  183. background: #efefef;
  184. width: 100%;
  185. height: 100vh;
  186. z-index: 1000000000;
  187. left: 0;
  188. right: 0;
  189. transition: top 0.5s;
  190. box-sizing: border-box;
  191. padding: 40rpx;
  192. .zhuangtaitubiao {
  193. width: 100%;
  194. height: auto;
  195. box-sizing: border-box;
  196. padding: 40rpx;
  197. background: #fff;
  198. border-radius: 20rpx;
  199. margin-bottom: 50rpx;
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. flex-direction: column;
  204. box-sizing: border-box;
  205. .textclass {
  206. font-size: 32rpx;
  207. font-weight: 500;
  208. box-sizing: border-box;
  209. }
  210. }
  211. .anniukuang {
  212. width: 100%;
  213. margin-bottom: 20rpx;
  214. box-sizing: border-box;
  215. box-sizing: border-box;
  216. }
  217. .title {
  218. font-size: 32rpx;
  219. font-weight: 500;
  220. align-items: left;
  221. box-sizing: border-box;
  222. }
  223. .row {
  224. display: flex;
  225. align-items: left;
  226. margin-top: 30rpx;
  227. width: 100%;
  228. box-sizing: border-box;
  229. // .label {
  230. // color: $sec-font;
  231. // }
  232. // .price {
  233. // color: $minor-color;
  234. // font-weight: 500;
  235. // }
  236. }
  237. }
  238. </style>