personal.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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.status ? "signs" : ""' @tap='signClick'>{{signState.status?"已签到":"签到"}}</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. mapActions
  79. } from "vuex"
  80. export default {
  81. data() {
  82. return {
  83. list:[
  84. {
  85. name: '设置',
  86. className: 'icon-shezhi',
  87. batName:"bindSeting"
  88. },
  89. {
  90. name: '问题反馈',
  91. className: 'icon-tishi',
  92. batName: "feedback"
  93. },
  94. {
  95. name: '剪切板',
  96. className: 'icon-document',
  97. batName: "bindCopy"
  98. },
  99. {
  100. name: '在线客服',
  101. className: 'icon-xiaoxizhongxin',
  102. batName: "bindService"
  103. }
  104. ]
  105. }
  106. },
  107. computed: {
  108. ...mapState({
  109. userInfo: state => state.global.userInfo,
  110. signState: state => state.global.signState,
  111. sing: state => state.global.sing
  112. })
  113. },
  114. onShow() {
  115. console.log(this.sing)
  116. },
  117. methods: {
  118. ...mapMutations(["setState", "setSing"]),
  119. ...mapActions(["Times"]),
  120. bind(signClick) {
  121. switch (signClick){
  122. case "bindSeting":
  123. this.bindSeting()
  124. break;
  125. case "bindCopy":
  126. this.bindCopy()
  127. break;
  128. default:
  129. break;
  130. }
  131. },
  132. bindSeting() {
  133. uni.navigateTo({
  134. url:"/pages/setting/setting"
  135. })
  136. },
  137. bindCopy() {
  138. let data = "haha"
  139. //#ifdef H5
  140. uni.showToast({
  141. title: '暂不支持H5端',
  142. duration: 2000,
  143. icon:"none"
  144. })
  145. //#endif
  146. //#ifndef H5
  147. uni.setClipboardData({
  148. data: data,
  149. success: res => {
  150. uni.showToast({
  151. title: '复制成功',
  152. duration: 2000
  153. })
  154. uni.getClipboardData({
  155. success: res=> {
  156. console.log(res.data)
  157. }
  158. })
  159. }
  160. })
  161. //#endif
  162. },
  163. signClick() {
  164. var obj = {}
  165. //#ifdef MP-WEIXIN
  166. if(this.userinfo) {
  167. //#endif
  168. if(this.signState.status) {
  169. return
  170. }else{
  171. this.Times().then((res) =>{
  172. obj.data = res
  173. obj.status = true
  174. this.setState(obj)
  175. })
  176. this.setSing(++this.sing)
  177. }
  178. //#ifdef MP-WEIXIN
  179. }else{
  180. uni.navigateTo({
  181. url:"/pages/login/login"
  182. })
  183. }
  184. //#endif
  185. },
  186. }
  187. }
  188. </script>