set.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="home">
  3. <view v-if="show" class="putWarp dffd">
  4. <block v-if="type == 1">
  5. <view class="putin bb dffs"><input @confirm="clickHandle" type="number" v-model="phone" placeholder="请输入手机号" /></view>
  6. <view class="putin bb dffs">
  7. <input type="text" v-model="code" placeholder="请输入短信验证码" />
  8. <verif :phone="phone"></verif>
  9. </view>
  10. </block>
  11. <block v-if="type == 2">
  12. <view class="putin dffs"><input @confirm="clickHandle" type="text" v-model="name" placeholder="请输入昵称" /></view>
  13. </block>
  14. <block v-if="type == 3">
  15. <view class="putin dffs"><input @confirm="clickHandle" type="text" v-model="school" placeholder="填写学校信息" /></view>
  16. </block>
  17. <block v-if="type == 4">
  18. <view class="putin spec bb dfsb">
  19. <text class="fontmid flex1">支付密码</text>
  20. <input @confirm="clickHandle" type="password" v-model="oldpass" placeholder="设置支付密码" />
  21. </view>
  22. </block>
  23. <block v-if="type == 6">
  24. <view class="putin spec bb dfsb">
  25. <text class="fontmid flex1">支付密码</text>
  26. <text class="fontmid textgrey">已设置</text>
  27. </view>
  28. </block>
  29. <block v-if="type == 5">
  30. <view class="putin bb dffs"><input @confirm="clickHandle" disabled="true" type="number" v-model="userInfo.userInfo.phone" placeholder="请输入手机号" /></view>
  31. <view class="putin bb dffs">
  32. <input type="text" v-model="code" placeholder="请输入短信验证码" />
  33. <verif :phone="userInfo.userInfo.phone"></verif>
  34. </view>
  35. <view class="putin spec bb dfsb">
  36. <text class="fontmid flex1">新密码</text>
  37. <input @confirm="clickHandle" type="password" v-model="newpass" placeholder="请输入新密码" />
  38. </view>
  39. <view class="putin spec bb dfsb">
  40. <text class="fontmid flex1">确认新密码</text>
  41. <input @confirm="clickHandle" type="password" v-model="two_pay_pass" placeholder="请输入确认新密码" />
  42. </view>
  43. </block>
  44. </view>
  45. <u-button color="#ED742F" iconColor="#fff" v-if="type != 6" @click="clickHandle" throttleTime="2000" shape="circle" class="custom-style" text="确定修改"></u-button>
  46. <u-button color="#ED742F" iconColor="#fff" v-if="type == 6" @click="type = 5" throttleTime="2000" shape="circle" class="custom-style" text="修改支付密码"></u-button>
  47. </view>
  48. </template>
  49. <script>
  50. import { mapState, mapActions } from 'vuex';
  51. import verif from '@/components/y-verif/verif.vue';
  52. export default {
  53. data() {
  54. return {
  55. show: false,
  56. type: '1', //1.手机号 2.昵称 3.学校信息 4.支付密码
  57. phone: '',
  58. code: '',
  59. name: '',
  60. school: '',
  61. oldpass: '',
  62. newpass: '',
  63. two_pay_pass:'',
  64. customStyle: {
  65. color: '#fff'
  66. }
  67. };
  68. },
  69. computed: {
  70. ...mapState({ userInfo: state => state.userInfo })
  71. },
  72. onLoad(opt) {
  73. this.type = opt.type || '1'; //1.手机号 2.昵称 3.学校信息 4.支付密码
  74. if (this.type == 1) {
  75. uni.setNavigationBarTitle({
  76. title: '更换手机号'
  77. });
  78. } else if (this.type == 2) {
  79. uni.setNavigationBarTitle({
  80. title: '修改昵称'
  81. });
  82. } else if (this.type == 3) {
  83. uni.setNavigationBarTitle({
  84. title: '学校信息'
  85. });
  86. } else if (this.type == 4) {
  87. uni.setNavigationBarTitle({
  88. title: '支付密码'
  89. });
  90. } else {
  91. }
  92. setTimeout(res => {
  93. this.show = true;
  94. }, 800);
  95. },
  96. onShow() {},
  97. methods: {
  98. clickHandle() {
  99. let url = '';
  100. let data = {};
  101. if (this.type == 1) {
  102. let phoneReg = /^(1[3-9])\d{9}$/;
  103. if (!phoneReg.test(this.phone)) {
  104. return this.$api.toast('手机号码不合法!');
  105. }
  106. if (!this.phone) {
  107. return this.$api.toast('请输入手机号', 1000);
  108. }
  109. if (!this.code) {
  110. return this.$api.toast('请输入短信验证码');
  111. }
  112. url = 'user/setPhone';
  113. data = {
  114. phone: this.phone,
  115. code: this.code
  116. };
  117. } else if (this.type == 2) {
  118. if (!this.name) {
  119. return this.$api.toast('请输入昵称');
  120. }
  121. url = 'user/changeNickname';
  122. data = {
  123. nickname: this.name
  124. };
  125. } else if (this.type == 3) {
  126. if (!this.school) {
  127. return this.$api.toast('请输入学校信息');
  128. }
  129. (url = 'user/changeSchool'),
  130. (data = {
  131. school: this.school
  132. });
  133. } else if (this.type == 4) {
  134. if (!this.oldpass) {
  135. return this.$api.toast('请输入密码');
  136. }
  137. url = 'user/setPayPass';
  138. data = {
  139. pass: this.oldpass
  140. };
  141. } else if (this.type == 5) {
  142. if (!this.userInfo.userInfo.phone) {
  143. return this.$api.toast('请输入手机号');
  144. }
  145. if (!this.code) {
  146. return this.$api.toast('请输入验证码');
  147. }
  148. if (!this.newpass) {
  149. return this.$api.toast('请输入新密码');
  150. }
  151. if (!this.two_pay_pass) {
  152. return this.$api.toast('请确认新密码');
  153. }if (this.newpass != this.two_pay_pass) {
  154. return this.$api.toast(' 新密码不一致');
  155. }
  156. url = 'user/newSetPassd';
  157. data = {
  158. phone: this.userInfo.userInfo.phone,
  159. code: this.code,
  160. pay_pass: this.newpass,
  161. two_pay_pass:this.two_pay_pass,
  162. };
  163. }
  164. this.$api
  165. .request(url, data)
  166. .then(data => {
  167. if (data.code == '200') {
  168. this.$api.toast(data.msg);
  169. setTimeout(res => {
  170. this.$store.dispatch('getUserInfo');
  171. uni.navigateBack({
  172. delta: 1
  173. });
  174. }, 300);
  175. } else {
  176. this.$api.toast(data.msg);
  177. }
  178. })
  179. .catch(function(error) {
  180. this.$api.toast(error);
  181. });
  182. }
  183. },
  184. components: {
  185. verif
  186. }
  187. };
  188. </script>
  189. <style lang="scss">
  190. .home {
  191. padding: 20rpx 0rpx 0;
  192. //yanzhengma
  193. .u-hairline-border[data-v-3bf2dba7]:after {
  194. border: 0;
  195. }
  196. .tips {
  197. padding: 0;
  198. color: $promain;
  199. font-size: 28rpx;
  200. line-height: 40rpx;
  201. height: 40rpx;
  202. }
  203. .putWarp {
  204. background-color: #fff;
  205. padding: 0rpx 32rpx;
  206. align-items: center;
  207. .putin {
  208. width: 100%;
  209. padding: 30rpx 0;
  210. &:nth-last-of-type(1) {
  211. border-bottom: 0px;
  212. }
  213. input {
  214. flex: 1;
  215. font-size: 28rpx;
  216. }
  217. .promain {
  218. border-left: 1px solid #dbdbdb;
  219. padding-left: 30rpx;
  220. }
  221. }
  222. .spec {
  223. input {
  224. text-align: right;
  225. }
  226. }
  227. }
  228. .custom-style {
  229. background-color: #0bb291;
  230. width: 690rpx;
  231. margin-top: 200rpx;
  232. text {
  233. color: #fff;
  234. }
  235. }
  236. }
  237. </style>