Shezhixiugai.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="title" tinColor="#006AFF" jiantou="0"></customNav>
  4. <view class="contentV">
  5. <view v-if="state==0">
  6. <view class="yzmctV">
  7. <view class="xialakuangct" @click="popgjm">
  8. <text>{{guojiadaima}}</text>
  9. <image style="width: 36rpx;height: 36rpx;padding-right: 16rpx;" src="/static/imags/xiala@3x.png" mode="scaleToFill"></image>
  10. </view>
  11. <input class="noinputV" type="number" :placeholder="$t('user.qsrshouihao')" @input="phoneinput">
  12. </view>
  13. <view class="yzmctV noinputVcode">
  14. <input class="" type="text" :placeholder="$t('user.yanzhengma')" @input="smsCodeinput">
  15. <label class="yzmbt" @click="getSMScode">{{yanzmnote}}</label>
  16. </view>
  17. </view>
  18. <view v-if="state==1">
  19. <view class="yzmctV">
  20. <input class="noinputVcode" password type="text" :placeholder="$t('user.qingshuydlmm')" :password="true" @input="inputA">
  21. </view>
  22. <view class="yzmctV">
  23. <input class="noinputVcode" password type="text" :placeholder="$t('user.qingshezmim')" :password="true" @input="inputB">
  24. </view>
  25. <view class="yzmctV">
  26. <input class="noinputVcode" password type="text" :placeholder="$t('user.qingzaisryc')" :password="true" @input="inputC">
  27. </view>
  28. </view>
  29. <view v-if="state==2">
  30. <view class="yzmctV">
  31. <input class="noinputVcode" type="safe-password" :placeholder="$t('user.qingshuyzfmm')" :password="true" @input="inputA">
  32. </view>
  33. <view class="yzmctV">
  34. <input class="noinputVcode" type="safe-password" :placeholder="$t('user.qingshezfmm')" :password="true" @input="inputB">
  35. </view>
  36. <view class="yzmctV">
  37. <input class="noinputVcode" type="safe-password" :placeholder="$t('user.qingzaisryc')" :password="true" @input="inputC">
  38. </view>
  39. </view>
  40. <view class="yzmctV">
  41. <label class="querenBt" @click="tijiaoAC">{{$t('index.tijiao')}}</label>
  42. </view>
  43. </view>
  44. <popViewGG :tips="$t('index.gjqhxz')" :show="showpop" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
  45. <picker-view :indicator-style="indicatorStyle" :value="pvalue" @change="bindChange" class="picker-view">
  46. <picker-view-column>
  47. <view class="item" v-for="(item,index) in range" :key="index">{{item}}</view>
  48. </picker-view-column>
  49. </picker-view>
  50. </popViewGG>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. smsCode,
  56. loginBySmsCode,
  57. setpassword,
  58. Bindingphone
  59. } from '@/pages/api/login';
  60. import { encrypt,decrypt } from '@/common/jsencrypt.js'
  61. export default {
  62. data() {
  63. return {
  64. pvalue: [0],
  65. indicatorStyle: `height: 50px;`,
  66. range: ["+86","+84","+886"],
  67. showpop:false,
  68. yanzmnote:this.$t('user.huoquyanzhegm'),
  69. timer:'',
  70. timeCall:0,
  71. telPhone:'',
  72. smsCode:'',
  73. guojiadaima:'86',
  74. title:'',
  75. state:-1,
  76. mimaA:'',
  77. mimaB:'',
  78. mimaC:''
  79. }
  80. },
  81. onLoad(option) {
  82. this.state = option.state;
  83. if(this.state==0){
  84. this.title = this.$t('user.bangdingsj')
  85. }
  86. if(this.state==1){
  87. this.title = this.$t('user.denglumima')
  88. }
  89. if(this.state==2){
  90. this.title = this.$t('user.zhifumima')
  91. }
  92. },
  93. methods: {
  94. tijiaoAC(){
  95. if(this.state==0){
  96. if(this.telPhone.length<1){
  97. uni.showToast({
  98. title: this.$t('user.qsrshouihao'),
  99. icon: 'none',
  100. duration: 3500
  101. })
  102. return;
  103. }
  104. if(this.smsCode.length==0){
  105. uni.showToast({
  106. title: this.$t('user.yanzhengma'),
  107. icon: 'none',
  108. duration: 3500
  109. })
  110. return;
  111. }
  112. this.Bindingphone();
  113. }
  114. if(this.state==1){
  115. if(this.mimaA.length==0){
  116. uni.showToast({
  117. title: this.$t('user.qingshuydlmm'),
  118. icon: 'none',
  119. duration: 3500
  120. })
  121. return;
  122. }
  123. if(this.mimaB.length==0){
  124. uni.showToast({
  125. title: this.$t('user.qingshezmim'),
  126. icon: 'none',
  127. duration: 3500
  128. })
  129. return;
  130. }
  131. if(this.mimaB!=this.mimaC){
  132. uni.showToast({
  133. title: 'Mật khẩu mới nhập hai lần không phù hợp',
  134. icon: 'none',
  135. duration: 3500
  136. })
  137. return;
  138. }
  139. this.setpassword();
  140. }
  141. if(this.state==2){
  142. uni.showToast({
  143. title: '待完善',
  144. icon: 'none',
  145. duration: 3500
  146. })
  147. }
  148. },
  149. inputA(event){
  150. this.mimaA = event.target.value;
  151. },
  152. inputB(event){
  153. this.mimaB = event.target.value;
  154. },
  155. inputC(event){
  156. this.mimaC = event.target.value;
  157. },
  158. bindChange (e) {
  159. var val = e.detail.value[0];
  160. this.guojiadaima=this.range[val];
  161. },
  162. popgjm(){
  163. this.showpop=true;
  164. },
  165. chooseCancel(){
  166. this.showpop=false;
  167. },
  168. phoneinput(event){
  169. this.telPhone = event.target.value;
  170. },
  171. smsCodeinput(event){
  172. this.smsCode = event.target.value;
  173. },
  174. getSMScode(){
  175. if(this.telPhone.length<1){
  176. uni.showToast({
  177. title: this.$t('user.qsrshouihao'),
  178. icon: 'none',
  179. duration: 3500
  180. })
  181. return;
  182. }
  183. if(this.timeCall==0){
  184. this.getSMScodeact();
  185. this.timeCall=60;
  186. }
  187. else{
  188. return;
  189. }
  190. var that = this;
  191. this.timer = setInterval(() => {
  192. that.timeCall=that.timeCall-1;
  193. if(that.timeCall==0){
  194. clearInterval(that.timer);
  195. that.yanzmnote = that.$t('user.huoquyanzhegm');
  196. }
  197. else{
  198. that.yanzmnote =that.$t('user.chongxinhq')+'('+that.timeCall+')';
  199. }
  200. }, 1000);
  201. },
  202. async getSMScodeact(){
  203. console.log("getSMScodeact");
  204. await this.$http.get(`${smsCode}`, {
  205. phone:this.guojiadaima+this.telPhone
  206. },false)
  207. .then(async r => {
  208. console.log(r)
  209. })
  210. .catch(err => {
  211. console.log(err)
  212. })
  213. },
  214. async setpassword(){
  215. var that = this;
  216. console.log(this.mimaA,this.mimaB)
  217. await this.$http.post(`${setpassword}`, {
  218. "password": encrypt(this.mimaA), //原密码
  219. "newpassword": encrypt(this.mimaB) //新密码
  220. },true)
  221. .then(async r => {
  222. console.log(r)
  223. if(r.data.code!=200){
  224. uni.showToast({
  225. title: r.data.msg,
  226. icon: 'none',
  227. duration: 3500
  228. })
  229. return;
  230. }
  231. uni.showToast({
  232. title: that.$t('user.shezhichengg'),
  233. icon: 'none',
  234. duration: 2000
  235. })
  236. setTimeout(() => {
  237. uni.setStorageSync('userInfo','');
  238. uni.setStorageSync('token','');
  239. uni.redirectTo({
  240. url:'/pages/user/LoginView'
  241. })
  242. }, 2000);
  243. })
  244. .catch(err => {
  245. console.log(err)
  246. uni.showToast({
  247. title: that.$t('user.shezhishibai'),
  248. icon: 'none',
  249. duration: 3500
  250. })
  251. })
  252. },
  253. async Bindingphone(){
  254. var that = this;
  255. console.log("Bindingphone");
  256. await this.$http.post(`${Bindingphone}`, {
  257. "telPhone": this.guojiadaima+this.telPhone,
  258. "code": this.smsCode
  259. },true)
  260. .then(async r => {
  261. console.log(r);
  262. uni.showToast({
  263. title: that.$t('user.shezhichengg'),
  264. icon: 'none',
  265. duration: 3500
  266. })
  267. })
  268. .catch(err => {
  269. console.log(err)
  270. uni.showToast({
  271. title: that.$t('user.shezhishibai'),
  272. icon: 'none',
  273. duration: 3500
  274. })
  275. })
  276. },
  277. },
  278. }
  279. </script>
  280. <style lang="scss">
  281. @import '@/common/common.scss';
  282. page{
  283. background-color: white;
  284. }
  285. .contentV{
  286. display: flex;
  287. width: 92%;
  288. margin-left: 4%;
  289. flex-direction: column;
  290. justify-content: flex-start;
  291. }
  292. .yzmctV{
  293. display: flex;
  294. flex-direction: row;
  295. align-items: center;
  296. justify-content:flex-start;
  297. margin-top: 30rpx;
  298. width: 100%;
  299. }
  300. .xialakuangct{
  301. display: flex;
  302. flex-direction: row;
  303. align-items: center;
  304. justify-content:space-between;
  305. padding-left: 16rpx;
  306. margin-right: 20rpx;
  307. width: 140rpx;
  308. height: 80rpx;
  309. line-height: 80rpx;
  310. border-radius: 10rpx;
  311. border: 2rpx solid #F2F3F7;
  312. background-color: #F2F3F7;
  313. }
  314. .noinputV{
  315. width: 73%;
  316. height: 80rpx;
  317. line-height: 80rpx;
  318. border-radius: 10rpx;
  319. border: 2rpx solid #F2F3F7;
  320. background-color: #F2F3F7;
  321. }
  322. .yzmbt{
  323. color: white;
  324. font-size: 26rpx;
  325. width: 170rpx;
  326. height: 60rpx;
  327. line-height: 60rpx;
  328. text-align: center;
  329. margin-left: auto;
  330. margin-right: 10rpx;
  331. border-radius: 2rpx;
  332. background-color:#60BA63;
  333. }
  334. .noinputVcode{
  335. width: 100%;
  336. height: 80rpx;
  337. line-height: 80rpx;
  338. border-radius: 10rpx;
  339. border: 2rpx solid #F2F3F7;
  340. background-color: #F2F3F7;
  341. }
  342. .querenBt{
  343. margin-top: 30rpx;
  344. width: 100%;
  345. height: 60rpx;
  346. line-height: 60rpx;
  347. padding: 10rpx;
  348. border-radius: 20rpx;
  349. text-align: center;
  350. justify-content: center;
  351. background-color: #006AFF;
  352. color: white;
  353. box-shadow: 0px 0rpx 10rpx 0rpx #006AFF;
  354. }
  355. .picker-view {
  356. width: 750rpx;
  357. height: 300rpx;
  358. margin-top: 10rpx;
  359. }
  360. .item {
  361. line-height: 100rpx;
  362. text-align: center;
  363. }
  364. </style>