uni-events-helper-wx
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
4.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <view class="content">
  3. <view class="login-box flex_col flex_start">
  4. <image class="bg" src="../../static/images/index/index_bg.png" mode="aspectFit"></image>
  5. <view class="login-info flex_col" v-if="hasLogin">
  6. <text>{{userInfo.mobile||"-"}}</text>
  7. <text>您好!</text>
  8. </view>
  9. <view class="button-login " v-else @click="jumpPage('login')">前往登录</view>
  10. </view>
  11. <view class="item flex_row flex_start bg-white padding solid-bottom" @click="jumpPage('messageList')">
  12. <image src="../../static/images/index/index_bell.png" mode=""></image>
  13. <view class="text-m text-left">消息中心</view>
  14. <view class="bandage" v-if="unReadNum">{{unReadNum}}</view>
  15. <image src="../../static/images/index/arrow_right.png" mode=""></image>
  16. </view>
  17. <view class="item flex_row flex_start bg-white padding solid-bottom" @click="clickEvent">
  18. <image src="../../static/images/index/index_cup.png" mode=""></image>
  19. <view class="text-m text-left">活动赛事</view>
  20. <image src="../../static/images/index/arrow_right.png" mode=""></image>
  21. </view>
  22. <view class="item flex_row flex_start bg-white padding solid-bottom" v-if="hasLogin" @click="logout">
  23. <image src="../../static/images/index/index_logout.png" mode=""></image>
  24. <view class="text-m text-left" >退出登录</view>
  25. <image src="../../static/images/index/arrow_right.png" mode=""></image>
  26. </view>
  27. <!-- <canvas style="width: 300px; height: 300px;" canvas-id="testcanvasId" id="testcanvasId"></canvas> -->
  28. </view>
  29. </template>
  30. <script>
  31. import { mapState,mapActions,mapGetters } from 'vuex'
  32. import {msgNum} from "../../nxTemp/apis/userAPI.js"
  33. export default {
  34. data() {
  35. return {
  36. address:"",
  37. login:false,
  38. unReadNum:""
  39. };
  40. },
  41. computed:{
  42. ...mapState(['userInfo']),
  43. ...mapGetters(['hasLogin']),
  44. },
  45. onShow() {
  46. this.updateMsgNum()
  47. this.testImage()
  48. },
  49. onLoad(opt) {
  50. },
  51. onUnload() {
  52. },
  53. methods: {
  54. ...mapActions(['getUserInfo','logoutUser']),
  55. jumpPage(name){
  56. this.$Router.push({name:name})
  57. },
  58. testImage(){
  59. var that =this
  60. let canvasId ="testcanvasId"
  61. // let imgPath = "/static/images/logo_main.png"
  62. let imgPath = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F8c39725605bf4e80e9763c58dbfb02482f98d87711069-qXPaNI_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1650531435&t=6f1744c5f84585eaef5dd1be6f83ae24"
  63. const ctx = uni.createCanvasContext(canvasId)
  64. ctx.drawImage(imgPath, 0, 0, 300, 300)
  65. ctx.draw(false, () => {
  66. uni.canvasGetImageData({
  67. canvasId: canvasId,
  68. x: 150,
  69. y: 150,
  70. width: 50,
  71. height: 50,
  72. success: (res) => {
  73. console.log(res.data[0] +' ' + res.data[1] +' ' + res.data[2])
  74. console.log("canvasGetImageData return:",res.data);
  75. },
  76. fail: res => {
  77. console.log(res)
  78. },
  79. }, that)
  80. })
  81. },
  82. updateMsgNum(){
  83. if(!this.hasLogin) return console.log("该用户还未登录");
  84. msgNum(this.postData).then(res => {
  85. this.unReadNum = res
  86. }).catch(e=>{
  87. // this.$tools.showNone(e.errMsg)
  88. })
  89. },
  90. async clickEvent(){
  91. if(this.hasLogin)this.jumpPage('eventList');
  92. else await this.$tools.showModal("该功能需要登录后才能查看,是否跳转去登录界面?",()=>{this.jumpPage('login')})
  93. },
  94. async logout(){
  95. await this.$tools.showModal("真的要退出登录?",this.logoutUser)
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="less" scoped>
  101. .content{
  102. .login-box{
  103. position: relative;
  104. width: 750rpx;
  105. height: 480rpx;
  106. > image ,.bg{
  107. width: 100%;height: 100%;
  108. position: absolute;
  109. z-index: 1;
  110. }
  111. .button-login{
  112. margin-top: 132rpx;
  113. color: #009874;
  114. z-index: 20;
  115. width: 240rpx;
  116. height: 96rpx;
  117. background: #FFFFFF;
  118. border-radius: 48rpx;
  119. text-align: center;
  120. line-height: 96rpx;
  121. font-weight: 900;
  122. font-size: 36rpx;
  123. letter-spacing: -0.2rpx;
  124. }
  125. .login-info{
  126. margin-top: 132rpx;
  127. z-index: 20;
  128. font-size: 40rpx;
  129. color: #FFFFFF;
  130. font-weight: 900;
  131. }
  132. }
  133. .item{
  134. color: #333333;
  135. position: relative;
  136. > image:first-child{
  137. width: 52rpx;
  138. height: 52rpx;
  139. margin-right: 14rpx;
  140. }
  141. > image:last-child{
  142. width: 30rpx;
  143. height: 30rpx;
  144. position: absolute;
  145. right: 20rpx;
  146. }
  147. .bandage{
  148. width: 34rpx;
  149. height: 34rpx;
  150. position: absolute;
  151. right: 60rpx;
  152. background: #EA5061;
  153. border-radius: 50%;
  154. font-size: 24rpx;
  155. color: white;
  156. text-align: center;
  157. line-height: 34rpx;
  158. }
  159. }
  160. }
  161. </style>