personal.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <style scoped lang="scss">
  2. .main{
  3. .portrait{
  4. display: flex;
  5. height: 160rpx;
  6. align-items: center;
  7. align-content: center;
  8. /* justify-content: center; 水平居中*/
  9. font-size: 30rpx;
  10. color: #fff;
  11. background-color: #49A3EE;
  12. .userinfo-avatar{
  13. border-radius: 50%;
  14. width: 100rpx;
  15. height: 100rpx;
  16. margin: 30rpx;
  17. }
  18. .sign{
  19. width: 120rpx;
  20. height: 60rpx;
  21. line-height: 60rpx;
  22. text-align: center;
  23. background-color: #fff;
  24. color: #49A3EE;
  25. border-radius: 10rpx;
  26. margin: 40rpx;
  27. margin-left: auto; /*子元素靠右 */
  28. }
  29. .signs{
  30. background: #fff;
  31. color: #666;
  32. }
  33. }
  34. .userlist{
  35. margin-top: 40rpx;
  36. .iconfont{
  37. margin-right: 10rpx;
  38. }
  39. button{
  40. flex: 1;
  41. position: absolute;
  42. top: 0;
  43. left: 0;
  44. width: 100%;
  45. height: 100%;
  46. opacity: 0;
  47. }
  48. }
  49. }
  50. </style>
  51. <template>
  52. <view class="main">
  53. <view class='portrait'>
  54. <image class="userinfo-avatar" :src="userInfo.avatarUrl ? userInfo.avatarUrl : '/static/icon.png'" mode="aspectFit"></image>
  55. <view>{{userInfo.nickName}}</view>
  56. <view class='sign' :class='signState ? "signs" : ""' @tap='signClick'>{{signState?"已签到":"签到"}}</view>
  57. </view>
  58. <view class='userlist cu-list menu'>
  59. <block v-for="(item, index) in list" :key="index">
  60. <view class='cu-item arrow' @tap="bind(item.batName)">
  61. <view class="content">
  62. <text class='iconfont' :class="item.className"></text>
  63. <text>{{item.name}}</text>
  64. </view>
  65. <!-- #ifdef MP-WEIXIN -->
  66. <button open-type="contact" v-if="item.batName === 'bindService'"/>
  67. <button open-type="feedback" v-if="item.batName === 'feedback'"/>
  68. <!-- #endif -->
  69. </view>
  70. </block>
  71. </view>
  72. </view>
  73. </template>
  74. <script >
  75. import {
  76. mapState,
  77. mapMutations
  78. } from "vuex"
  79. export default {
  80. data() {
  81. return {
  82. list:[
  83. {
  84. name: '设置',
  85. className: 'icon-shezhi',
  86. batName:"bindSeting"
  87. },
  88. {
  89. name: '问题反馈',
  90. className: 'icon-tishi',
  91. batName: "feedback"
  92. },
  93. {
  94. name: '剪切板',
  95. className: 'icon-document',
  96. batName: "bindCopy"
  97. },
  98. {
  99. name: '在线客服',
  100. className: 'icon-xiaoxizhongxin',
  101. batName: "bindService"
  102. }
  103. ]
  104. }
  105. },
  106. computed: {
  107. ...mapState({
  108. userInfo: state => state.global.userInfo,
  109. signState: state => state.global.signState,
  110. sing: state => state.global.sing
  111. })
  112. },
  113. onShow() {
  114. console.log(this.sing)
  115. },
  116. methods: {
  117. ...mapMutations(["setState", "setSing"]),
  118. bind(signClick) {
  119. switch (signClick){
  120. case "bindSeting":
  121. this.bindSeting()
  122. break;
  123. case "bindCopy":
  124. this.bindCopy()
  125. break;
  126. default:
  127. break;
  128. }
  129. },
  130. bindSeting() {
  131. uni.navigateTo({
  132. url:"/pages/setting/setting"
  133. })
  134. },
  135. bindCopy() {
  136. let data = "haha"
  137. //#ifdef H5
  138. uni.showToast({
  139. title: '暂不支持H5端',
  140. duration: 2000,
  141. icon:"none"
  142. })
  143. //#endif
  144. //#ifndef H5
  145. uni.setClipboardData({
  146. data: data,
  147. success: res => {
  148. uni.showToast({
  149. title: '复制成功',
  150. duration: 2000
  151. })
  152. uni.getClipboardData({
  153. success: res=> {
  154. console.log(res.data)
  155. }
  156. })
  157. }
  158. })
  159. //#endif
  160. },
  161. signClick() {
  162. if(this.signState) {
  163. return
  164. }else{
  165. this.setState(true)
  166. console.log(++this.sing)
  167. this.setSing(++this.sing)
  168. }
  169. },
  170. }
  171. }
  172. </script>