ledouHexiao.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="content">
  3. <u-form :model="form" :error-type="['toast']" :label-width="180" ref="uForm">
  4. <u-form-item label="收取门店">
  5. <view class="txt-right">{{form.storeName}}</view>
  6. </u-form-item>
  7. <u-form-item label="支付用户">
  8. <view class="txt-right">{{form.phone}}</view>
  9. </u-form-item>
  10. <u-form-item label="备注" prop="remark">
  11. <u-input placeholder="请输入备注" :maxlength="500" :custom-style="{textAlign:'right'}" trim v-model="form.remark" />
  12. </u-form-item>
  13. <u-form-item label="核销数量" label-position="top" prop="ledou" required>
  14. <view class="ledu-input">
  15. <view><u-input placeholder="请输入核销数量" :custom-style="{borderBottom:'1px solid #999',textAlign:'center',width:'100%'}" trim type="number" v-model="form.ledou" /></view>
  16. <text>个乐豆</text>
  17. </view>
  18. </u-form-item>
  19. <view class="form-button">
  20. <u-button type="primary" @click="submit">确认核销</u-button>
  21. </view>
  22. </u-form>
  23. <!-- 确认核销弹窗 -->
  24. <u-popup mode="center" :mask-close-able="false" closeable @close="closeModal" negative-top="300" v-model="showModal" width="600rpx" >
  25. <view class="slot-content">
  26. <view class="slot-title">请输入验证码</view>
  27. <view class="text-cont">
  28. <view>
  29. <text>用户手机:</text>
  30. <text>{{form.phone||'--'}}</text>
  31. </view>
  32. </view>
  33. <view class="text-cont">
  34. <view>
  35. <text>验证码:</text>
  36. <u-input type="number" placeholder="请输入验证码"></u-input>
  37. <u-button size="mini" :disabled="isDisable" @click="getCodeValidate">{{nowVal}}</u-button>
  38. </view>
  39. </view>
  40. <view class="fot-btn">
  41. <u-button @click="confirm" size="medium" type="primary" >确定</u-button>
  42. </view>
  43. </view>
  44. </u-popup>
  45. <!-- 图文验证码 -->
  46. <uni-popup ref="imageTxtPopup" type="center">
  47. <popup-con type="forgetImageTxt" title="图文验证码" :popBtn="popBtn" :changeImg="changeImg" @captchaImg="captchaImg"></popup-con>
  48. </uni-popup>
  49. </view>
  50. </template>
  51. <script>
  52. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  53. import popupCon from '@/components/uni-popup/popup-con.vue'
  54. import { memberVerifyCode, memberGetByMobile } from '@/api/user.js'
  55. export default {
  56. components: {
  57. uniPopup,
  58. popupCon
  59. },
  60. data() {
  61. return {
  62. showModal: false,
  63. nowVal: '获取验证码', // 按钮显示内容
  64. count: '', // 当前秒数
  65. timer: null, // 倒计时
  66. isDisable: false, // 是否禁止获取验证码
  67. changeImg: false, // 是否重新更换图形验证码
  68. randomCode: '', // 图片验证码随机码
  69. form:{
  70. storeName: '收取门店',
  71. phone: '13709146191',
  72. remark: '',
  73. ledou: ''
  74. },
  75. rules: {
  76. ledou: [
  77. {
  78. required: true,
  79. type: 'number',
  80. message: '请输入乐豆',
  81. // 可以单个或者同时写两个触发验证方式
  82. trigger: ['change','blur'],
  83. }
  84. ],
  85. remark: [
  86. {
  87. message: '请输入备注',
  88. trigger: 'change'
  89. }
  90. ]
  91. }
  92. }
  93. },
  94. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  95. onReady() {
  96. this.$refs.uForm.setRules(this.rules);
  97. },
  98. methods: {
  99. submit() {
  100. this.$refs.uForm.validate(valid => {
  101. console.log(valid)
  102. if (valid) {
  103. console.log('验证通过');
  104. this.showModal = true
  105. } else {
  106. console.log('验证失败');
  107. }
  108. });
  109. },
  110. closeModal(){
  111. this.showModal = false
  112. },
  113. // 确定验证码
  114. confirm(){
  115. },
  116. // 获取验证码
  117. getCodeValidate(){
  118. if(this.form.phone){
  119. // 校验手机号是否注册过
  120. memberGetByMobile({phone: this.form.phone}).then(res => {
  121. if(res.status == 200){
  122. // 图文验证码
  123. this.$refs.imageTxtPopup.open()
  124. }else{
  125. uni.showToast({icon: 'none',title: res.message})
  126. }
  127. })
  128. }else{
  129. uni.showToast({icon: 'none',title: '请先输入手机号'})
  130. }
  131. },
  132. // 开始倒计时
  133. getCodeFun(){
  134. const TIME_COUNT = 60
  135. if (!this.timer) {
  136. this.count = TIME_COUNT
  137. this.timer = setInterval(() => {
  138. if (this.count > 0 && this.count <= TIME_COUNT) {
  139. this.count--
  140. this.nowVal = this.count + 's后重发'
  141. this.isDisable = true
  142. } else {
  143. this.nowVal = '重新获取验证码'
  144. clearInterval(this.timer)
  145. this.timer = null
  146. this.isDisable = false
  147. }
  148. }, 1000)
  149. }
  150. },
  151. // 图文验证码
  152. captchaImg(code, nowRandomCode){
  153. this.captchaVerify(code, nowRandomCode)
  154. },
  155. // 验证图片验证码
  156. captchaVerify(code, nowRandomCode){
  157. const _this = this
  158. let obj = {}
  159. obj.phone = this.form.phone
  160. obj.random = nowRandomCode
  161. obj.captcha = code
  162. // 短信验证码
  163. memberVerifyCode(obj).then(res => {
  164. console.log(JSON.stringify(res))
  165. if(res.status == 200){ // 验证码输入正确
  166. _this.randomCode = nowRandomCode // 图片验证码随机码
  167. // 关闭 图形验证码 弹框
  168. _this.$refs.imageTxtPopup.close()
  169. // 开启倒计时
  170. this.getCodeFun()
  171. uni.showToast({icon: 'none',title: '验证码发送成功'})
  172. }else { // 验证码输入错误
  173. _this.randomCode = ''
  174. // 切换验证码重新校验
  175. _this.changeImg = false
  176. _this.$nextTick(function(){
  177. _this.changeImg = true
  178. })
  179. uni.showToast({icon: 'none',title: res.message})
  180. }
  181. })
  182. },
  183. }
  184. }
  185. </script>
  186. <style lang="less">
  187. .content{
  188. width: 100%;
  189. padding: 20upx 40upx;
  190. background: #FFFFFF;
  191. .ledu-input{
  192. width: 60%;
  193. margin: 0 auto;
  194. display: flex;
  195. align-items: center;
  196. > text{
  197. width: 150rpx;
  198. }
  199. }
  200. .form-button{
  201. padding: 60upx;
  202. }
  203. .txt-right{
  204. text-align: right;
  205. width: 100%;
  206. }
  207. .slot-content{
  208. padding: 30upx 0;
  209. display: flex;
  210. flex-direction: column;
  211. align-items: center;
  212. justify-content: space-between;
  213. .slot-title{
  214. font-size: 30rpx;
  215. padding: 20rpx 0;
  216. }
  217. .text-cont{
  218. width: 100%;
  219. margin-top: 10upx;
  220. >view {
  221. padding: 15upx 40upx;
  222. display: flex;
  223. align-items: center;
  224. >text{
  225. &:first-child {
  226. margin: 0 10upx;
  227. width: 130upx;
  228. }
  229. }
  230. .u-input{
  231. border-bottom: 1px solid #999;
  232. margin: 0 15rpx;
  233. text-align: center;
  234. }
  235. }
  236. }
  237. .footer{
  238. width: 80%;
  239. border-bottom: 1px solid #b1b1b1;
  240. >input {
  241. text-align: center;
  242. padding: 10upx 0;
  243. }
  244. }
  245. .fot-btn{
  246. margin-top: 30upx;
  247. }
  248. }
  249. }
  250. </style>