nc-payment.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view class="container" v-if="payInfo">
  3. <view class="uni-flex uni-column payment-wrap" v-show="paystatus == 'pay'">
  4. <view class="header">结算</view>
  5. <view class="body">
  6. <view class="info-wrap">
  7. <scroll-view scroll-y="true" class="info">
  8. <view class="payment-money">费用总额:¥{{ payInfo.original_money | moneyFormat }}</view>
  9. <block v-if="promotionShow">
  10. <view class="title">营销优惠</view>
  11. <view class="uni-flex">
  12. <view
  13. class="type-item"
  14. :class="{ disabled: payInfo.offset.coupon_array.member_coupon_list.length == 0, active: discount.coupon_id }"
  15. @click="selectCoupon"
  16. v-if="payInfo.offset.coupon_array"
  17. >
  18. <view class="iconfont iconyouhuiquan"></view>
  19. <view class="name" v-show="!discount.coupon_id">
  20. 优惠券
  21. <text class="text" v-if="payInfo.offset.coupon_array.member_coupon_list.length">
  22. ({{ payInfo.offset.coupon_array.member_coupon_list.length }}张可用)
  23. </text>
  24. </view>
  25. <view class="name" v-show="discount.coupon_id">
  26. 优惠券抵扣
  27. <text class="text">{{ payInfo.coupon_money }}元</text>
  28. </view>
  29. <view class="iconfont iconxuanzhong"></view>
  30. </view>
  31. <view class="type-item" :class="{ active: discount.reduction }" @click="reduction" v-if="payInfo.collectmoney_config.reduction == 1">
  32. <view class="iconfont iconjianmianjine"></view>
  33. <view
  34. class="name"
  35. v-if="discount.reduction"
  36. @click.stop="openMoneyPopup({ title: '减免金额', money: $util.moneyFormat(discount.reduction), type: 'reduction' })"
  37. >
  38. 减免
  39. <text class="text">{{ discount.reduction }}元</text>
  40. </view>
  41. <view v-else class="name">减免金额</view>
  42. <view class="iconfont iconxuanzhong"></view>
  43. </view>
  44. </view>
  45. </block>
  46. <block v-if="payInfo.offset.point_array || payInfo.offset.balance">
  47. <view class="title">账户抵扣</view>
  48. <view class="uni-flex">
  49. <view class="type-item" :class="{ active: discount.is_use_balance, disabled: balance == 0 }" @click="useBalance" v-if="payInfo.offset.balance">
  50. <view class="iconfont iconyue"></view>
  51. <view class="name" v-if="discount.is_use_balance">
  52. 余额支付
  53. <text class="text">{{ payInfo.total_balance | moneyFormat }}元</text>
  54. </view>
  55. <view class="name" v-else>
  56. 账户余额
  57. <text class="text" v-if="balance > 0">{{ balance | moneyFormat }}元</text>
  58. </view>
  59. <view class="iconfont iconxuanzhong"></view>
  60. </view>
  61. <view
  62. class="type-item"
  63. :class="{ active: discount.is_use_point, disabled: payInfo.offset.point_array.point == 0 }"
  64. @click="usePoint"
  65. v-if="payInfo.offset.point_array"
  66. >
  67. <view class="iconfont iconjifen1"></view>
  68. <view class="name" v-if="discount.is_use_point">
  69. 积分抵扣
  70. <text class="text">{{ payInfo.point_money | moneyFormat }}元({{ parseInt(payInfo.offset.point_array.point) }}积分)</text>
  71. </view>
  72. <view class="name" v-else>
  73. 账户积分
  74. <text class="text" v-if="memberInfo.point">{{ memberInfo.point }}积分</text>
  75. </view>
  76. <view class="iconfont iconxuanzhong"></view>
  77. </view>
  78. </view>
  79. </block>
  80. <view class="title">支付方式</view>
  81. <view class="uni-flex pay-type">
  82. <block v-for="(item, index) in payType" :key="index">
  83. <view
  84. class="type-item"
  85. @click="switchPayType(item.type)"
  86. :class="{ active: item.type == type }"
  87. v-if="payInfo.collectmoney_config.pay_type.indexOf(item.type) != -1"
  88. >
  89. <view class="pay-icon iconfont" :style="{ background: item.background }" :class="item.icon"></view>
  90. <view class="name">{{ item.name }}</view>
  91. <view class="iconfont iconxuanzhong"></view>
  92. </view>
  93. </block>
  94. </view>
  95. <view class="remark-info" v-if="payInfo.remark">备注:{{ payInfo.remark }}</view>
  96. </scroll-view>
  97. <view class="button-wrap">
  98. <view class="print-ticket">
  99. <checkbox-group @change="autoPrintTicket = !autoPrintTicket">
  100. <label>
  101. <checkbox :checked="autoPrintTicket" style="transform:scale(0.7)" />
  102. <text>打印小票</text>
  103. </label>
  104. </checkbox-group>
  105. </view>
  106. <button class="default-btn" @click="openRemark">备注</button>
  107. <button class="default-btn cancel-btn" plain @click="cancelPayment">取消</button>
  108. <button class="primary-btn" @click="confirm()" v-if="(type != 'third' && type != 'member_paymentcode') || payInfo.pay_money == 0">确认</button>
  109. <button class="primary-btn" @click="thirdConfirm()" v-else>确认</button>
  110. </view>
  111. </view>
  112. <scroll-view scroll-y="true" class="bill-wrap">
  113. <view class="title">支付明细</view>
  114. <view class="body">
  115. <view class="bill-info">
  116. <view>费用总额</view>
  117. <view>¥{{ payInfo.original_money | moneyFormat }}</view>
  118. </view>
  119. <view class="block-title"><text>营销优惠</text></view>
  120. <view class="bill-info">
  121. <view>减免金额</view>
  122. <view class="text">-¥{{ payInfo.offset.reduction ? $util.moneyFormat(payInfo.offset.reduction) : '0.00' }}</view>
  123. </view>
  124. <view class="bill-info" v-if="payInfo.offset.coupon_array">
  125. <view>优惠券</view>
  126. <view class="text">-¥{{ $util.moneyFormat(payInfo.coupon_money) }}</view>
  127. </view>
  128. <view class="bill-info" v-if="payInfo.offset.hongbao_array">
  129. <view>红包</view>
  130. <view class="text">-¥{{ $util.moneyFormat(payInfo.hongbao_money) }}</view>
  131. </view>
  132. <view class="bill-info" v-if="payInfo.offset.point_array">
  133. <view>积分抵扣</view>
  134. <view class="text">-¥{{ $util.moneyFormat(payInfo.point_money) }}</view>
  135. </view>
  136. <block v-if="payInfo.offset.balance">
  137. <view class="block-title"><text>余额抵扣</text></view>
  138. <view class="bill-info">
  139. <view>余额支付</view>
  140. <view>-¥{{ $util.moneyFormat(payInfo.total_balance) }}</view>
  141. </view>
  142. </block>
  143. <view class="block-title"><text>支付方式</text></view>
  144. <view class="bill-info">
  145. <view>{{ payType[type].name }}</view>
  146. <view v-show="type == 'cash'">¥{{ payInfo.cash > 0 ? $util.moneyFormat(payInfo.cash) : $util.moneyFormat(payInfo.pay_money) }}</view>
  147. <view v-show="type != 'cash'">¥{{ payInfo.pay_money | moneyFormat }}</view>
  148. </view>
  149. <view class="block-title"></view>
  150. <view class="bill-info">
  151. <view>需支付</view>
  152. <view>¥{{ payInfo.pay_money | moneyFormat }}</view>
  153. </view>
  154. <view class="bill-info">
  155. <view>实付</view>
  156. <view v-show="type == 'cash'">¥{{ payInfo.cash > 0 ? $util.moneyFormat(payInfo.cash) : $util.moneyFormat(payInfo.pay_money) }}</view>
  157. <view v-show="type != 'cash'">¥{{ payInfo.pay_money | moneyFormat }}</view>
  158. </view>
  159. <view class="bill-info" v-if="payInfo.cash_change > 0">
  160. <view>找零</view>
  161. <view>¥{{ payInfo.cash_change | moneyFormat }}</view>
  162. </view>
  163. </view>
  164. </scroll-view>
  165. </view>
  166. </view>
  167. <!-- 支付结果 -->
  168. <view class="uni-flex uni-column pay-result" v-show="paystatus == 'success'">
  169. <view class="body status">
  170. <view class="iconfont iconchenggong"></view>
  171. <view class="msg">收款成功</view>
  172. </view>
  173. <view class="footer">
  174. <button class="primary-btn" @click="paySuccess">继续收款({{ autoComplete.time }}s)</button>
  175. </view>
  176. </view>
  177. <uni-popup ref="moneyPopup" type="center">
  178. <view class="money-wrap">
  179. <view class="head">
  180. <text>{{ moneyPopup.title }}</text>
  181. <text class="iconfont iconguanbi1" @click="$refs.moneyPopup.close()"></text>
  182. </view>
  183. <view class="content-wrap">
  184. <view class="unit">¥</view>
  185. <view class="money">{{ moneyPopup.money }}</view>
  186. </view>
  187. <view class="keyboard-wrap">
  188. <view class="num-wrap">
  189. <view class="key-item" @click="keydown('1')">1</view>
  190. <view class="key-item" @click="keydown('2')">2</view>
  191. <view class="key-item" @click="keydown('3')">3</view>
  192. <view class="key-item" @click="keydown('4')">4</view>
  193. <view class="key-item" @click="keydown('5')">5</view>
  194. <view class="key-item" @click="keydown('6')">6</view>
  195. <view class="key-item" @click="keydown('7')">7</view>
  196. <view class="key-item" @click="keydown('8')">8</view>
  197. <view class="key-item" @click="keydown('9')">9</view>
  198. <view class="key-item" @click="keydown('00')">00</view>
  199. <view class="key-item" @click="keydown('0')">0</view>
  200. <view class="key-item" @click="keydown('.')">.</view>
  201. </view>
  202. <view class="operation-wrap">
  203. <view class="delete" @click="deleteCode">删除</view>
  204. <view class="delete" @click="moneyPopup.money = ''">清空</view>
  205. <view class="confirm" @click="moneyPopupConfirm">确认</view>
  206. </view>
  207. </view>
  208. </view>
  209. </uni-popup>
  210. <uni-popup ref="couponPopup" type="center" v-if="payInfo.offset.coupon_array && payInfo.offset.coupon_array.member_coupon_list.length">
  211. <view class="coupon-wrap">
  212. <view class="head">
  213. <text>选择优惠券</text>
  214. <text class="iconfont iconguanbi1" @click="$refs.couponPopup.close()"></text>
  215. </view>
  216. <scroll-view scroll-y="true" class="body">
  217. <view class="list">
  218. <view
  219. class="item"
  220. :class="{ active: discount.coupon_id && discount.coupon_id == item.coupon_id }"
  221. v-for="(item, index) in payInfo.offset.coupon_array.member_coupon_list"
  222. :key="index"
  223. @click="selectCouponItem(item)"
  224. >
  225. <view class="money" v-show="item.type == 'discount'">
  226. {{ item.discount }}
  227. <text class="unit">折</text>
  228. </view>
  229. <view class="money" v-show="item.type != 'discount'">
  230. <text class="unit">¥</text>
  231. {{ item.coupon_money }}
  232. </view>
  233. <view class="info">
  234. <view class="title">{{ item.coupon_name }}</view>
  235. <view class="limit">
  236. {{ item.at_least == 0 ? '无门槛券' : '满' + item.at_least + '可用' }}
  237. {{ item.type == 'discount' && item.discount_limit > 0 ? ',最多优惠' + item.discount_limit : '' }}
  238. </view>
  239. <view class="time" v-if="item.end_time">{{ item.end_time | timeFormat('y-m-d') }}前可用</view>
  240. <view class="time" v-else>长期有效</view>
  241. </view>
  242. <view class="iconfont iconxuanzhong"></view>
  243. </view>
  244. </view>
  245. </scroll-view>
  246. </view>
  247. </uni-popup>
  248. <!-- 扫码枪支付弹窗 -->
  249. <uni-popup ref="thirdPopup" type="center" @change="popupChange">
  250. <view class="third-popup">
  251. <view class="head">
  252. <text>请选择扫码方式</text>
  253. <text class="iconfont iconguanbi1" @click="$refs.thirdPopup.close()"></text>
  254. </view>
  255. <view class="money">扫码收款¥{{ payInfo.pay_money | moneyFormat }}</view>
  256. <view class="scan-code-type" v-if="type == 'third'">
  257. <view class="type-item" :class="{ active: scanCodeType == 'scancode' }" @click="scanCodeType = 'scancode'">扫码枪</view>
  258. <view class="type-item" :class="{ active: scanCodeType == 'qrcode' }" @click="scanCodeType = 'qrcode'">二维码</view>
  259. </view>
  260. <view class="content-wrap">
  261. <view class="qrcode-wrap" v-show="scanCodeType == 'qrcode'">
  262. <block v-if="payQrcode.length">
  263. <view class="qrcode-item" v-for="(item, index) in payQrcode" :key="index">
  264. <image :src="item.qrcode.replace(/[\r\n]/g, '')" mode="widthFix" class="qrcode" v-if="item.qrcode.indexOf('data:image') != -1"></image>
  265. <image :src="$util.img(item.qrcode)" mode="widthFix" class="qrcode" v-else></image>
  266. <image :src="$util.img(item.logo)" mode="widthFix" class="logo"></image>
  267. </view>
  268. </block>
  269. <view class="empty" v-else>没有可用的收款二维码</view>
  270. </view>
  271. <view class="scancode-wrap" v-show="scanCodeType == 'scancode'">
  272. <input
  273. type="number"
  274. v-model="authCode"
  275. :class="{ focus: scancodeFocus }"
  276. :focus="scancodeFocus"
  277. placeholder="请点击输入框聚焦扫码或输入付款码"
  278. @confirm="scancode"
  279. @focus="scancodeFocus = true"
  280. @blur="scancodeFocus = false"
  281. />
  282. <image :src="$util.img('public/uniapp/cashier/scan_code_tip.png')" mode="widthFix"></image>
  283. </view>
  284. </view>
  285. </view>
  286. </uni-popup>
  287. <!-- 付款码验证 -->
  288. <uni-popup ref="paymentCodePopup" type="center">
  289. <view class="third-popup member">
  290. <view class="head">
  291. <text>请扫描会员付款码</text>
  292. <text class="iconfont iconguanbi1" @click="$refs.paymentCodePopup.close()"></text>
  293. </view>
  294. <view class="content-wrap">
  295. <view class="scancode-wrap" v-show="scanCodeType == 'scancode'">
  296. <input
  297. type="number"
  298. v-model="authCode"
  299. :class="{ focus: scancodeFocus }"
  300. :focus="scancodeFocus"
  301. placeholder="请点击输入框聚焦扫码或输入付款码"
  302. @confirm="scancode"
  303. @focus="scancodeFocus = true"
  304. @blur="scancodeFocus = false"
  305. />
  306. <image :src="$util.img('public/uniapp/cashier/scan_code_tip.png')" mode="widthFix"></image>
  307. </view>
  308. </view>
  309. </view>
  310. </uni-popup>
  311. <!-- 验证手机号 -->
  312. <uni-popup ref="safeVerifyPopup" type="center">
  313. <view class="safe-verify-popup">
  314. <view class="header">
  315. <view class="type-wrap" v-if="payInfo.collectmoney_config.sms_verify == 1">
  316. <view class="item" :class="{ active: safeVerifyType == 'payment_code' }" @click="safeVerifyType = 'payment_code'">付款码</view>
  317. <view class="item" :class="{ active: safeVerifyType == 'sms_code' }" @click="safeVerifyType = 'sms_code'">短信验证码</view>
  318. </view>
  319. <text class="iconfont iconguanbi1" @click="$refs.safeVerifyPopup.close()"></text>
  320. </view>
  321. <view class="content" v-show="safeVerifyType == 'payment_code'">
  322. <view class="scancode-wrap">
  323. <view class="input-wrap">
  324. <input
  325. type="number"
  326. v-model="paymentCode"
  327. :class="{ focus: scancodeFocus }"
  328. :focus="scancodeFocus"
  329. placeholder="点击输入框聚焦扫码或输入动态码"
  330. @confirm="verifyPaymentCode"
  331. @focus="scancodeFocus = true"
  332. @blur="scancodeFocus = false"
  333. placeholder-class="placeholder"
  334. />
  335. <button class="primary-btn" @click="verifyPaymentCode">确认</button>
  336. </view>
  337. <image :src="$util.img('public/uniapp/cashier/scan_code_tip.png')" mode="widthFix"></image>
  338. </view>
  339. </view>
  340. <view class="content" v-show="safeVerifyType == 'sms_code'">
  341. <block v-if="payInfo.member_account">
  342. <view class="tip">将发送验证码到该手机</view>
  343. <view class="mobile">{{ payInfo.member_account.mobile.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2') }}</view>
  344. <view class="sms-code">
  345. <input type="number" v-model="smsCode" class="sms-code" placeholder="请输入验证码" placeholder-class="placeholder" />
  346. <text class="send-tip" @click="sendMobileCode" :class="{ disabled: dynacodeData.isSend }">{{ dynacodeData.codeText }}</text>
  347. </view>
  348. <button class="primary-btn" @click="verifySmsCode">确认</button>
  349. </block>
  350. <view v-else>该会员尚未绑定手机号,无法使用该验证方式</view>
  351. </view>
  352. </view>
  353. </uni-popup>
  354. <uni-popup ref="remarkPopup" type="center">
  355. <view class="remark-wrap">
  356. <view class="header">
  357. <text class="title">备注</text>
  358. <text class="iconfont iconguanbi1" @click="$refs.remarkPopup.close()"></text>
  359. </view>
  360. <view class="body"><textarea v-model="remark" placeholder="填写备注信息" placeholder-class="placeholder-class" /></view>
  361. <view class="footer"><button type="default" class="primary-btn" @click="remarkConfirm">确认</button></view>
  362. </view>
  363. </uni-popup>
  364. </view>
  365. </template>
  366. <script>
  367. import payment from './nc-payment.js';
  368. export default {
  369. name: 'ncPayment',
  370. mixins: [payment]
  371. };
  372. </script>
  373. <style lang="scss">
  374. @import './nc-payment.scss';
  375. </style>