Shezhixiugai.vue 8.6 KB

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