setting-wechat.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="container">
  3. <view class="h-method flex-row justify-center">
  4. <view class="btn flex-row justify-center " @click="bindWechat()">
  5. <view class="h-img flex-col justify-center">
  6. <u-icon name="weixin-fill" color="green" size="30"></u-icon>
  7. </view>
  8. <view class="h-name ">
  9. <text>绑定当前登录微信号</text>
  10. </view>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. userInfo: {
  20. auth: true,
  21. openId: ''
  22. },
  23. tips2: '',
  24. }
  25. },
  26. onReady() {
  27. },
  28. onLoad() {
  29. // 用户信息
  30. let user = uni.getStorageSync('userInfo');
  31. this.userInfo.openId = user.openId;
  32. },
  33. methods: {
  34. // 绑定微信
  35. bindWechat(){
  36. // 保存数据
  37. this.$api.bindWechat(this.userInfo).then((res)=>{
  38. uni.showToast({
  39. title: '绑定成功'
  40. })
  41. setTimeout(function() {
  42. // 选择完成后返回上一页
  43. uni.navigateBack({
  44. delta: 1,
  45. success: function(res) {
  46. console.log('返回成功');
  47. }
  48. });
  49. }, 2000); // 延迟2秒执行
  50. }).catch(() =>{
  51. uni.showToast({
  52. title: "操作失败"
  53. })
  54. });
  55. },
  56. }
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. @import '/common/css/common.css';
  61. page,body{
  62. background: #F7F7F7;
  63. }
  64. .container{
  65. }
  66. .h-method{
  67. height: 100vh;
  68. background: #f7f7f7;
  69. }
  70. .btn{
  71. width: 686rpx;
  72. height: 100rpx;
  73. background: #FFFFFF;
  74. border-radius: 50rpx;
  75. margin-top: 35vh;
  76. .h-name{
  77. line-height: 100rpx;
  78. }
  79. }
  80. </style>