my-list-item.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view>
  3. <view class="home-list-item d-flex a-center j-sb animated fadeIn fast" hover-class="home-list-hover"
  4. @tap="clickevent">
  5. <view class="d-flex a-center">
  6. <view v-if="item.icon" class="icon iconfont" :class="['icon-'+item.icon]"></view> {{item.name}}
  7. </view>
  8. <view class="d-flex a-center j-center rightText">
  9. {{item.text}}
  10. <view class="icon iconfont" :class="{'icon-youjiantou':!item.data}">{{item.data || ''}}</view>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. const PACKAGE_INFO_KEY = '__package_info__'
  17. export default {
  18. data() {
  19. return {}
  20. },
  21. props: {
  22. item: Object,
  23. index: Number,
  24. someData: {
  25. type: Boolean,
  26. default: null,
  27. },
  28. },
  29. methods: {
  30. clickevent() {
  31. console.log(this.someData)
  32. switch (this.item.clicktype) {
  33. case "navigateTo":
  34. if (this.item.url) {
  35. let option = {
  36. url: this.item.url
  37. };
  38. if (this.item.auth) {
  39. return this.navigate(option, 'navigateTo', true);
  40. }
  41. uni.navigateTo(option);
  42. }
  43. break;
  44. case "switchTab":
  45. if (this.item.url) {
  46. let option = {
  47. url: this.item.url
  48. };
  49. if (this.item.auth) {
  50. return this.navigate(option, 'switchTab', true);
  51. }
  52. uni.switchTab(option);
  53. }
  54. break;
  55. case "clear":
  56. uni.showModal({
  57. title: '提示',
  58. content: '是否要清除缓存?',
  59. confirmText: '立刻清除',
  60. success: res => {
  61. if (res.confirm) {
  62. uni.showToast({
  63. title: '清除缓存成功!',
  64. icon: "none"
  65. });
  66. }
  67. },
  68. });
  69. break;
  70. case "weixin":
  71. if (this.someData) {
  72. uni.showToast({
  73. title: '已绑定',
  74. icon: 'none'
  75. });
  76. } else {
  77. this.bindother();
  78. }
  79. break;
  80. case "nothing":
  81. uni.showToast({
  82. title: '更新中...',
  83. icon: 'none'
  84. });
  85. break;
  86. }
  87. },
  88. // 绑定第三方登录
  89. bindother() {
  90. uni.login({
  91. provider: 'weixin',
  92. onlyAuthorize: true,
  93. success: (res) => {
  94. this.codeRes(res.code)
  95. },
  96. fail: (err) => {
  97. uni.showToast({
  98. title: '绑定失败',
  99. icon: "none"
  100. });
  101. }
  102. });
  103. },
  104. async codeRes(code) {
  105. let res = await this.$http.post("/wechat/bind", {
  106. code: code,
  107. })
  108. this.$emit('weixinMsg', res);
  109. },
  110. }
  111. }
  112. </script>
  113. <style scoped>
  114. .home-list-item {
  115. padding: 20upx;
  116. border-top: 1upx solid #F4F4F4;
  117. border-bottom: 1upx solid #F4F4F4;
  118. }
  119. .home-list-item>view:first-child {
  120. color: #333333;
  121. }
  122. .home-list-item>view:first-child>view {
  123. margin-right: 10upx;
  124. font-size: 32upx;
  125. }
  126. .home-list-item>view:last-child {
  127. color: #CCCCCC;
  128. }
  129. .home-list-hover {
  130. background: #f4f4f4;
  131. }
  132. .rightText {
  133. font-size: 30upx;
  134. }
  135. .icon {
  136. margin-left: 10upx;
  137. font-size: 24upx;
  138. }
  139. </style>