setting-wechat.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. this.userInfo.openId = uni.getStorageSync('userInfoOpenId');
  31. },
  32. methods: {
  33. // 绑定微信
  34. bindWechat(){
  35. // 保存数据
  36. this.$api.bindWechat(this.userInfo).then((res)=>{
  37. uni.showToast({
  38. title: '绑定成功'
  39. })
  40. setTimeout(function() {
  41. // 选择完成后返回上一页
  42. uni.navigateBack({
  43. delta: 1,
  44. success: function(res) {
  45. console.log('返回成功');
  46. }
  47. });
  48. }, 2000); // 延迟2秒执行
  49. }).catch(() =>{
  50. uni.showToast({
  51. title: "操作失败"
  52. })
  53. });
  54. },
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. @import '/common/css/common.css';
  60. page,body{
  61. background: #F7F7F7;
  62. }
  63. .container{
  64. }
  65. .h-method{
  66. height: 100vh;
  67. background: #f7f7f7;
  68. }
  69. .btn{
  70. width: 686rpx;
  71. height: 100rpx;
  72. background: #FFFFFF;
  73. border-radius: 50rpx;
  74. margin-top: 35vh;
  75. .h-name{
  76. line-height: 100rpx;
  77. }
  78. }
  79. </style>