uni-Cell.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <view class="cell" :style="{ borderRadius: round }">
  4. <view class="cellItem dis a-c j-s" v-for="(item, index) in celllist" :key="index" @tap="cellClick(item)">
  5. <view class="left dis a-c">
  6. <image v-if="item.icon" :src="item.icon" mode=""></image>
  7. <text class="leftTitle" :style="leftStyle">{{ item.title }}</text>
  8. </view>
  9. <view class="Right dis a-c">
  10. <view class="mr-1 dis a-c j-c">
  11. <text v-if="item.value" style="font-size: ;">{{ item.value }}</text>
  12. <slot v-else name="customContent" :item="item" :index="index">
  13. </slot>
  14. </view>
  15. <image v-if="item.rightIcon !== undefined ? item.rightIcon : rightIcon" class="rightArrow"
  16. src="/static/icon/my/arrowRight.png" mode="">
  17. </image>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 更新组件 force 是否强制更新 tabbar:页面是否有原生tabbar组件-->
  22. <app-update ref="app_update" @status="updateStatus"></app-update>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. mapState,
  28. mapMutations
  29. } from "vuex"
  30. import appUpdate from "@/components/yzhua006-update/app-update"; //app更新组件
  31. export default {
  32. components: {
  33. appUpdate,
  34. },
  35. props: {
  36. // 单元格列表
  37. celllist: {
  38. type: Array,
  39. default: () => []
  40. },
  41. /*圆角 */
  42. round: {
  43. type: String,
  44. default: '0'
  45. },
  46. leftStyle: {
  47. type: Object,
  48. default: () => {}
  49. },
  50. rightIcon: {
  51. type: Boolean,
  52. default: true,
  53. }
  54. },
  55. data() {
  56. return {
  57. hasUpdate: false,
  58. };
  59. },
  60. watch: {
  61. hasUpdate(newVal, oldVal) {
  62. this.hasUpdate = newVal
  63. },
  64. },
  65. computed: {
  66. ...mapState(['userInfo']),
  67. },
  68. methods: {
  69. //菜单点击回调
  70. cellClick(item) {
  71. if (typeof item.handler === 'function') {
  72. // 如果配置了 handler,直接执行
  73. item.handler(item);
  74. return;
  75. }
  76. switch (item.clickType) {
  77. case 'navigate':
  78. if (item.url) {
  79. uni.navigateTo({
  80. url: item.url,
  81. })
  82. } else {
  83. uni.showToast({
  84. title: '链接错误,无法跳转',
  85. icon: "none"
  86. });
  87. }
  88. break;
  89. case 'checkVersion': //检查版本
  90. this.$refs.app_update.update(); //调用子组件检查更新方法
  91. break;
  92. case 'auth': //实名认证 0.未认证 1. 认证成功 2. 认证驳回"
  93. if (this.userInfo.sysUser.authStatus == 1) {
  94. uni.navigateTo({
  95. url: '/pages/my/identityInfo'
  96. })
  97. } else {
  98. uni.navigateTo({
  99. url: '/pages/my/realNameAuth'
  100. })
  101. }
  102. break;
  103. case 'weChat': //微信
  104. break;
  105. case 'alipay': //支付宝
  106. break;
  107. case 'clear': //清除缓存
  108. uni.showModal({
  109. title: '提示',
  110. content: '是否要清除缓存?',
  111. confirmText: '立刻清除',
  112. success: res => {
  113. if (res.confirm) {
  114. uni.showToast({
  115. title: '清除缓存成功!',
  116. icon: "none"
  117. });
  118. }
  119. },
  120. });
  121. break;
  122. default:
  123. }
  124. },
  125. updateStatus(item) {
  126. this.hasUpdate = item;
  127. if (!this.hasUpdate) {
  128. uni.showToast({
  129. title: '已经是最新版本',
  130. icon: "none"
  131. });
  132. }
  133. }
  134. },
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .cell {
  139. width: 100%;
  140. background: #FFFFFF;
  141. padding: 0 30rpx;
  142. box-sizing: border-box;
  143. .cellItem {
  144. padding: 30rpx 0;
  145. box-sizing: border-box;
  146. border-bottom: 1rpx solid #eee;
  147. // 左侧
  148. .left {
  149. image {
  150. width: 40rpx;
  151. height: 40rpx;
  152. margin-right: 20rpx;
  153. }
  154. .leftTitle {
  155. font-size: 28rpx;
  156. color: #333;
  157. }
  158. }
  159. .Right {
  160. width: auto;
  161. font-size: 30rpx;
  162. color: #666;
  163. .rightArrow {
  164. width: 30rpx;
  165. height: 30rpx;
  166. }
  167. }
  168. }
  169. :last-child {
  170. border-bottom: none;
  171. }
  172. }
  173. </style>