index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="ChangePassword">
  4. <form @submit="editPoint">
  5. <!-- <view class="phone">当前手机号:{{phone}}</view> -->
  6. <view class="list">
  7. <view class="item">
  8. <input type='number' placeholder='请输入节点ID' placeholder-class='placeholder' name="point" :value="point"></input>
  9. </view>
  10. <!-- <view class="item">
  11. <input type='password' placeholder='确认新密码' placeholder-class='placeholder' name="qr_password" :value="qr_password"></input>
  12. </view>
  13. <view class="item acea-row row-between-wrapper">
  14. <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput" name="captcha" :value="captcha"></input>
  15. <button class="code font-num" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  16. {{ text }}
  17. </button>
  18. </view> -->
  19. </view>
  20. <button form-type="submit" class="confirmBnt bg-color">确认提交</button>
  21. </form>
  22. </view>
  23. <Verify @success="success" :captchaType="'blockPuzzle'" :imgSize="{ width: '330px', height: '155px' }"
  24. ref="verify"></Verify>
  25. <!-- #ifdef MP -->
  26. <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
  27. <!-- #endif -->
  28. </view>
  29. </template>
  30. <script>
  31. import sendVerifyCode from "@/mixins/SendVerifyCode";
  32. import {
  33. tradePassword,
  34. registerVerify,
  35. verifyCode,
  36. setPoint
  37. } from '@/api/api.js';
  38. import {
  39. getUserInfo,
  40. getCodeApi
  41. } from '@/api/user.js';
  42. import {
  43. toLogin
  44. } from '@/libs/login.js';
  45. import {
  46. mapGetters
  47. } from "vuex";
  48. import colors from '@/mixins/color.js';
  49. import Verify from '@/components/verify/verify.vue';
  50. export default {
  51. mixins: [sendVerifyCode,colors],
  52. components: {
  53. Verify
  54. },
  55. data() {
  56. return {
  57. point: '',
  58. captcha: '',
  59. userInfo: {},
  60. phone: '',
  61. password: '',
  62. qr_password: '',
  63. isAuto: false, //没有授权的不会自动授权
  64. isShowAuth: false ,//是否隐藏授权
  65. key: '',
  66. };
  67. },
  68. computed: mapGetters(['isLogin']),
  69. watch:{
  70. isLogin:{
  71. handler:function(newV,oldV){
  72. if(newV){
  73. //#ifndef MP
  74. this.getUserInfo();
  75. this.getVerifyCode();
  76. //#endif
  77. }
  78. },
  79. deep:true
  80. }
  81. },
  82. onLoad() {
  83. if (this.isLogin) {
  84. this.getUserInfo();
  85. this.getVerifyCode();
  86. } else {
  87. //#ifndef MP
  88. toLogin();
  89. //#endif
  90. //#ifdef MP
  91. this.isShowAuth = true;
  92. //#endif
  93. }
  94. },
  95. onShow() {
  96. uni.removeStorageSync('form_type_cart');
  97. },
  98. methods: {
  99. /**
  100. * 授权回调
  101. */
  102. onLoadFun: function(e) {
  103. this.getUserInfo();
  104. this.getVerifyCode();
  105. this.isShowAuth = false;
  106. },
  107. // 授权关闭
  108. authColse: function(e) {
  109. this.isShowAuth = e
  110. },
  111. getVerifyCode(){
  112. verifyCode().then(res=>{
  113. this.$set(this, 'key', res.data.key)
  114. });
  115. },
  116. /**
  117. * 获取个人用户信息
  118. */
  119. getUserInfo: function() {
  120. let that = this;
  121. getUserInfo().then(res => {
  122. let tel = res.data.phone;
  123. let phone = tel.substr(0, 3) + "****" + tel.substr(7);
  124. that.$set(that, 'userInfo', res.data);
  125. that.phone = phone;
  126. });
  127. },
  128. success(data) {
  129. console.log(data,'data');
  130. this.$refs.verify.hide()
  131. getCodeApi()
  132. .then(res => {
  133. this.keyCode = res.data.key;
  134. this.getCode(data);
  135. })
  136. .catch(res => {
  137. this.$util.Tips({
  138. title: res
  139. });
  140. });
  141. },
  142. /**
  143. * 发送验证码
  144. *
  145. */
  146. code(data) {
  147. let that = this;
  148. if (!that.userInfo.phone) return that.$util.Tips({
  149. title: '手机号码不存在,无法发送验证码!'
  150. });
  151. this.$refs.verify.show()
  152. },
  153. async getCode(data){
  154. console.log('data-------',data);
  155. let that = this;
  156. await registerVerify({
  157. phone: that.userInfo.phone,
  158. type: 'reset',
  159. key: that.key,
  160. captchaType: 'blockPuzzle',
  161. captchaVerification: data.captchaVerification,
  162. })
  163. .then(res => {
  164. that.$util.Tips({
  165. title: res.msg
  166. });
  167. that.sendCode();
  168. })
  169. .catch(res => {
  170. that.$util.Tips({
  171. title: res
  172. });
  173. });
  174. },
  175. /**
  176. * 设置节点
  177. *
  178. */
  179. editPoint: function(e) {
  180. let that = this,
  181. point = e.detail.value.point;
  182. // qr_password = e.detail.value.qr_password,
  183. // captcha = e.detail.value.captcha;
  184. if (!point) return that.$util.Tips({
  185. title: '请输入节点ID'
  186. });
  187. // if (qr_password != password) return that.$util.Tips({
  188. // title: '两次输入的密码不一致!'
  189. // });
  190. // if (!captcha) return that.$util.Tips({
  191. // title: '请输入验证码'
  192. // });
  193. setPoint({
  194. // account: that.userInfo.phone,
  195. // captcha: captcha,
  196. // password: password
  197. puid: point
  198. }).then(res => {
  199. return that.$util.Tips({
  200. title: res.msg
  201. }, {
  202. tab: 3,
  203. url: 1
  204. });
  205. }).catch(err => {
  206. return that.$util.Tips({
  207. title: err
  208. });
  209. });
  210. }
  211. }
  212. }
  213. </script>
  214. <style lang="scss">
  215. page {
  216. background-color: #fff !important;
  217. }
  218. .ChangePassword .phone {
  219. font-size: 32rpx;
  220. font-weight: bold;
  221. text-align: center;
  222. margin-top: 55rpx;
  223. }
  224. .ChangePassword .list {
  225. width: 580rpx;
  226. margin: 53rpx auto 0 auto;
  227. }
  228. .ChangePassword .list .item {
  229. width: 100%;
  230. height: 110rpx;
  231. border-bottom: 2rpx solid #f0f0f0;
  232. }
  233. .ChangePassword .list .item input {
  234. width: 100%;
  235. height: 100%;
  236. font-size: 32rpx;
  237. }
  238. .ChangePassword .list .item .placeholder {
  239. color: #b9b9bc;
  240. }
  241. .ChangePassword .list .item input.codeIput {
  242. width: 340rpx;
  243. }
  244. .ChangePassword .list .item .code {
  245. font-size: 32rpx;
  246. background-color: #fff;
  247. }
  248. .ChangePassword .list .item .code.on {
  249. color: #b9b9bc !important;
  250. }
  251. .ChangePassword .confirmBnt {
  252. font-size: 32rpx;
  253. width: 580rpx;
  254. height: 90rpx;
  255. border-radius: 45rpx;
  256. color: #fff;
  257. margin: 92rpx auto 0 auto;
  258. text-align: center;
  259. line-height: 90rpx;
  260. }
  261. </style>