index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="passwordset-content" :style="{'--status-bar-': statusBarHeight}">
  3. <view class="passwordset-content-info">
  4. <!-- 头部主要内容 开始 -->
  5. <view class="passwordset-content-header">
  6. <customNavbar
  7. title="支付密码设置"
  8. bgColor="var(--gd-bgm-color)"
  9. :contentStyle="{color: '#fff'}"
  10. :leftStyle="{color: '#fff'}"
  11. ></customNavbar>
  12. </view>
  13. <!-- 头部主要内容 结束 -->
  14. <!-- userInfo内容 开始 -->
  15. <view class="passwordset-content-password">
  16. <text>{{ tip[actionIndex] }}</text>
  17. <view>
  18. <u-code-input v-model="value" @finish="finish" :focus="true" dot></u-code-input>
  19. </view>
  20. </view>
  21. <!-- userInfo内容 结束 -->
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import { navigateTo } from "@/utils/util.js"
  27. export default {
  28. data() {
  29. return {
  30. title: '这是我的',
  31. statusBarHeight: 0, // 状态栏安全距离
  32. value: "",
  33. tip: ["输入当前密码,用于确认身份","设置六位数数字密码","再次输入"],
  34. actionIndex: 0,
  35. password: '',
  36. withdrawInfo: {}
  37. }
  38. },
  39. onLoad() {
  40. },
  41. onShow() {
  42. this.statusBarHeight = getApp().globalData.statusBarHeight
  43. this.getWithdrawInfo()
  44. },
  45. methods: {
  46. /**
  47. * @author ygh
  48. * @data 2023-12-20
  49. */
  50. navigateToFun(item){
  51. navigateTo(item.url)
  52. },
  53. finish(){
  54. if(this.actionIndex == 0) { // 认证密码
  55. this.marketPersons()
  56. }else if(this.actionIndex == 1) {
  57. uni.showLoading({
  58. title: "下一步"
  59. })
  60. this.password = this.value
  61. setTimeout(()=>{
  62. this.$set(this,'value', '')
  63. this.actionIndex += 1
  64. console.log("this.value==",this.value)
  65. uni.hideLoading()
  66. },500)
  67. }else if(this.actionIndex == 2) {
  68. if(this.password != this.value){
  69. uni.showToast({
  70. title: '两次密码不一样',
  71. icon: 'none'
  72. });
  73. this.getWithdrawInfo()
  74. }else {
  75. this.payset()
  76. }
  77. }
  78. },
  79. /**
  80. * 获取用户密码信息
  81. */
  82. async getWithdrawInfo() {
  83. try{
  84. this.password = ''
  85. this.value = ''
  86. let res = await this.$u.api.withdrawInfo({
  87. noSign: 1,
  88. userid: this.distribution_user_info.userId
  89. })
  90. if(res && res.code ===200) {
  91. this.withdrawInfo = res.data
  92. if(this.withdrawInfo.ifPaySet== 0) {
  93. this.actionIndex = 1
  94. }else {
  95. this.actionIndex = 0
  96. }
  97. }
  98. }catch(e){
  99. //TODO handle the exception
  100. console.error("e===",e)
  101. }
  102. },
  103. /**
  104. * 密码校验
  105. */
  106. async marketPersons() {
  107. try{
  108. uni.showLoading({
  109. title: "认证中..."
  110. })
  111. let res = await this.$u.api.marketPersons({
  112. noSign: 1,
  113. userid: this.distribution_user_info.userId,
  114. oldPassword: this.value
  115. })
  116. if(res && res.code ===200) {
  117. this.value = ''
  118. this.actionIndex += 1
  119. uni.hideLoading()
  120. uni.showToast({
  121. title: '认证成功',
  122. icon: 'none'
  123. });
  124. } else {
  125. this.value = ''
  126. uni.showToast({
  127. title: res.msg,
  128. icon: 'none'
  129. });
  130. }
  131. }catch(e){
  132. //TODO handle the exception
  133. console.error("e===",e)
  134. this.value = ''
  135. uni.showToast({
  136. title: "认证失败",
  137. icon: 'none'
  138. });
  139. }
  140. },
  141. /**
  142. * 设置密码
  143. */
  144. async payset() {
  145. try{
  146. let res = await this.$u.api.payset({
  147. noSign: 1,
  148. userid: this.distribution_user_info.userId,
  149. newPassword: this.value
  150. })
  151. if(res && res.code ===200) {
  152. uni.showToast({
  153. title: "设置成功",
  154. icon: 'none'
  155. });
  156. uni.navigateBack({
  157. delta: 1
  158. })
  159. } else {
  160. uni.showToast({
  161. title: "设置失败",
  162. icon: 'none'
  163. });
  164. this.getWithdrawInfo()
  165. }
  166. }catch(e){
  167. //TODO handle the exception
  168. console.error("e===",e)
  169. uni.showToast({
  170. title: "设置失败",
  171. icon: 'none'
  172. });
  173. this.getWithdrawInfo()
  174. }
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .passwordset-content {
  181. display: flex;
  182. flex-direction: column;
  183. align-items: center;
  184. justify-content: center;
  185. --header-h: 90rpx;
  186. .passwordset-content-info {
  187. width: 100%;
  188. box-sizing: border-box;
  189. }
  190. }
  191. /** 头部主要内容 开始 */
  192. .passwordset-content-header {
  193. width: 100%;
  194. height: var(--header-h);
  195. box-sizing: border-box;
  196. ::v-deep .u-search {
  197. padding: 0 30rpx !important;
  198. }
  199. ::v-deep .u-search__action {
  200. color: #fff !important;
  201. }
  202. }
  203. /** 头部主要内容 结束 **/
  204. /** password内容 开始 */
  205. .passwordset-content-password {
  206. width: 100%;
  207. padding: 40rpx 40rpx 0;
  208. box-sizing: border-box;
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: center;
  212. >text {
  213. text-align: center;
  214. }
  215. >view {
  216. margin-top: 40rpx;
  217. display: flex;
  218. justify-content: center;
  219. }
  220. }
  221. /** password内容 结束 */
  222. </style>