uni-Cell.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. <!-- 更新组件:结果通过 update() 的返回值拿回,不再依赖事件桥接 -->
  22. <app-update ref="app_update"></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. latestVersion: '', // 检测到的最新版本号
  59. };
  60. },
  61. computed: {
  62. ...mapState(['userInfo']),
  63. },
  64. methods: {
  65. //菜单点击回调
  66. cellClick(item) {
  67. if (typeof item.handler === 'function') {
  68. // 如果配置了 handler,直接执行
  69. item.handler(item);
  70. return;
  71. }
  72. switch (item.clickType) {
  73. case 'navigate':
  74. if (item.url) {
  75. uni.navigateTo({
  76. url: item.url,
  77. })
  78. } else {
  79. uni.showToast({
  80. title: '链接错误,无法跳转',
  81. icon: "none"
  82. });
  83. }
  84. break;
  85. case 'checkVersion': //检查版本
  86. //#ifdef APP-PLUS
  87. // 直接通过 update() 的返回值拿检查结果,不走事件桥接
  88. // 返回值结构:{ hasUpdate, latestVersion }
  89. this.$refs.app_update.update().then((res) => {
  90. this.updateStatus(res);
  91. }).catch((e) => {
  92. console.error('[checkVersion] 检查更新失败:', e);
  93. });
  94. //#endif
  95. // 非app端不检查更新
  96. //#ifdef H5
  97. uni.showToast({
  98. title: '请在App中操作',
  99. icon: "none"
  100. });
  101. //#endif
  102. break;
  103. case 'auth': //实名认证 0.未认证 1. 认证成功 2. 认证驳回"
  104. if (this.userInfo.sysUser.authStatus == 1) {
  105. uni.navigateTo({
  106. url: '/pages/my/identityInfo'
  107. })
  108. } else {
  109. uni.navigateTo({
  110. url: '/pages/my/realNameAuth'
  111. })
  112. }
  113. break;
  114. case 'weChat': //微信
  115. break;
  116. case 'alipay': //支付宝
  117. break;
  118. case 'clear': //清除缓存
  119. uni.showModal({
  120. title: '提示',
  121. content: '是否要清除缓存?',
  122. confirmText: '立刻清除',
  123. success: res => {
  124. if (res.confirm) {
  125. uni.showToast({
  126. title: '清除缓存成功!',
  127. icon: "none"
  128. });
  129. }
  130. },
  131. });
  132. break;
  133. default:
  134. }
  135. },
  136. // 检查结果回调:item = { hasUpdate, latestVersion }
  137. updateStatus(item) {
  138. this.hasUpdate = item.hasUpdate;
  139. if (item.latestVersion) {
  140. this.latestVersion = item.latestVersion;
  141. }
  142. if (!this.hasUpdate) {
  143. uni.showToast({
  144. title: '已经是最新版本',
  145. icon: "none"
  146. });
  147. }
  148. }
  149. },
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .cell {
  154. width: 100%;
  155. background: #FFFFFF;
  156. padding: 0 30rpx;
  157. box-sizing: border-box;
  158. .cellItem {
  159. padding: 30rpx 0;
  160. box-sizing: border-box;
  161. border-bottom: 1rpx solid #eee;
  162. // 左侧
  163. .left {
  164. image {
  165. width: 40rpx;
  166. height: 40rpx;
  167. margin-right: 20rpx;
  168. }
  169. .leftTitle {
  170. font-size: 28rpx;
  171. color: #333;
  172. }
  173. }
  174. .Right {
  175. width: auto;
  176. font-size: 30rpx;
  177. color: #666;
  178. .rightArrow {
  179. width: 30rpx;
  180. height: 30rpx;
  181. }
  182. }
  183. }
  184. :last-child {
  185. border-bottom: none;
  186. }
  187. }
  188. </style>