safe.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="body">
  3. <!-- 公共组件-每个页面必须引入 -->
  4. <public-module></public-module>
  5. <block v-for="(item,index) in list" :key="index">
  6. <my-list-item :item="item" :index="index" @weixinMsg="weixinMsg" @zhifubaoMsg="zhifubaoMsg"
  7. :someData="status"></my-list-item>
  8. </block>
  9. </view>
  10. </template>
  11. <script>
  12. import {
  13. mapState
  14. } from "vuex"
  15. import myListItem from "@/components/modules/my/my-list-item.vue";
  16. export default {
  17. components: {
  18. myListItem
  19. },
  20. data() {
  21. return {
  22. list: [{
  23. icon: "",
  24. name: "修改密码",
  25. clicktype: "navigateTo",
  26. url: "/pages/set/password",
  27. text: "去设置",
  28. auth: true
  29. },
  30. {
  31. icon: "",
  32. name: "修改手机号",
  33. clicktype: "navigateTo",
  34. url: "/pages/set/mobile",
  35. text: '',
  36. auth: true
  37. },
  38. {
  39. icon: "",
  40. name: "微信",
  41. clicktype: "weixin",
  42. url: "",
  43. text: '未绑定',
  44. },
  45. {
  46. icon: "",
  47. name: "支付宝",
  48. clicktype: "zhifubao",
  49. url: "",
  50. text: '未绑定',
  51. },
  52. ],
  53. status: {
  54. weixinstatus: false,
  55. zhifubaostatus: false,
  56. }
  57. }
  58. },
  59. async onLoad() {
  60. this.list[1].text = this.userInfo.sysUser.mobile;
  61. this.bindingStatus();
  62. this.isBindAlipay();
  63. },
  64. async onShow() {
  65. let args = plus.runtime.arguments;
  66. if (args) {
  67. plus.runtime.arguments = null; //进入之后就把urlscheme清空要不然下一次oushow时还会执行
  68. // 处理args参数,如直达到某新页面等
  69. //通过code请求获取user_id
  70. var authCode = args.split("=")[1];
  71. if (authCode != undefined && authCode != "" && authCode != null) {
  72. let res = await this.$http.post("/alipay/bind", {
  73. code: authCode,
  74. })
  75. if (res.code == '200') {
  76. uni.showToast({
  77. title: res.msg,
  78. icon: "success"
  79. });
  80. this.isBindAlipay();
  81. } else {
  82. uni.showToast({
  83. title: res.msg,
  84. icon: "none"
  85. });
  86. }
  87. }
  88. }
  89. },
  90. computed: {
  91. ...mapState(["userInfo"])
  92. },
  93. methods: {
  94. async bindingStatus() {
  95. let res = await this.$http.get("/user/isBindWechat")
  96. if (res.code == '200') {
  97. this.list[2].text = "已绑定"
  98. this.status.weixinstatus = true;
  99. } else {
  100. this.status.weixinstatus = false;
  101. }
  102. },
  103. async isBindAlipay() {
  104. let res = await this.$http.get("/alipay/isBindAlipay")
  105. if (res.code == '200') {
  106. this.list[3].text = "已绑定"
  107. this.status.zhifubaostatus = true;
  108. } else {
  109. this.status.zhifubaostatus = false;
  110. }
  111. },
  112. weixinMsg(res) {
  113. if (res.code == '200') {
  114. uni.showToast({
  115. title: res.msg,
  116. icon: "success"
  117. });
  118. this.bindingStatus();
  119. } else {
  120. uni.showToast({
  121. title: res.msg,
  122. icon: "none"
  123. });
  124. }
  125. },
  126. zhifubaoMsg(res) {
  127. if (res.code == '200') {
  128. uni.showToast({
  129. title: res.msg,
  130. icon: "success"
  131. });
  132. this.isBindAlipay();
  133. } else {
  134. uni.showToast({
  135. title: res.msg,
  136. icon: "none"
  137. });
  138. }
  139. }
  140. }
  141. }
  142. </script>
  143. <style>
  144. </style>