my-list-item.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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: Object
  25. },
  26. onShow() {
  27. //获取支付宝回调code
  28. },
  29. methods: {
  30. clickevent() {
  31. switch (this.item.clicktype) {
  32. case "navigateTo":
  33. if (this.item.url) {
  34. let option = {
  35. url: this.item.url
  36. };
  37. if (this.item.auth) {
  38. return this.navigate(option, 'navigateTo', true);
  39. }
  40. uni.navigateTo(option);
  41. }
  42. break;
  43. case "switchTab":
  44. if (this.item.url) {
  45. let option = {
  46. url: this.item.url
  47. };
  48. if (this.item.auth) {
  49. return this.navigate(option, 'switchTab', true);
  50. }
  51. uni.switchTab(option);
  52. }
  53. break;
  54. case "clear":
  55. uni.showModal({
  56. title: '提示',
  57. content: '是否要清除缓存?',
  58. confirmText: '立刻清除',
  59. success: res => {
  60. if (res.confirm) {
  61. uni.showToast({
  62. title: '清除缓存成功!',
  63. icon: "none"
  64. });
  65. }
  66. },
  67. });
  68. break;
  69. case "weixin":
  70. if (this.someData.weixinstatus) {
  71. uni.showToast({
  72. title: '已绑定',
  73. icon: 'none'
  74. });
  75. } else {
  76. this.bindother();
  77. }
  78. break;
  79. case "zhifubao":
  80. if (this.someData.zhifubaostatus) {
  81. uni.showToast({
  82. title: '已绑定',
  83. icon: 'none'
  84. });
  85. } else {
  86. this.zhofubaobindother();
  87. }
  88. break;
  89. case "nothing":
  90. uni.showToast({
  91. title: '更新中...',
  92. icon: 'none'
  93. });
  94. break;
  95. }
  96. },
  97. // 绑定微信
  98. bindother() {
  99. uni.login({
  100. provider: 'weixin',
  101. onlyAuthorize: true,
  102. success: (res) => {
  103. this.codeRes(res.code)
  104. },
  105. fail: (err) => {
  106. uni.showToast({
  107. title: '绑定失败',
  108. icon: "none"
  109. });
  110. }
  111. });
  112. },
  113. // 绑定支付宝
  114. zhofubaobindother() {
  115. let urls =
  116. 'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021004153668213&scope=auth_user&redirect_uri=https://test.baoxianzhanggui.com/pay/';
  117. urls = encodeURIComponent(urls); //将地址编码成浏览器访问的格式
  118. plus.runtime.openURL(
  119. 'alipays://platformapi/startapp?appId=20000067&url=' + urls,
  120. res => {
  121. //这里写打开URL地址失败后的处理0
  122. console.log(res);
  123. uni.showModal({
  124. content: '本机未检测到对应客户端,是否打开浏览器访问页面?',
  125. success: function(res) {
  126. if (res.confirm) {
  127. //plus.runtime.openURL();
  128. }
  129. }
  130. });
  131. },
  132. 'com.eg.android.AlipayGphone'
  133. );
  134. },
  135. async codeRes(code) {
  136. let res = await this.$http.post("/wechat/bind", {
  137. code: code,
  138. })
  139. this.$emit('weixinMsg', res);
  140. },
  141. }
  142. }
  143. </script>
  144. <style scoped>
  145. .home-list-item {
  146. padding: 20upx;
  147. border-top: 1upx solid #F4F4F4;
  148. border-bottom: 1upx solid #F4F4F4;
  149. }
  150. .home-list-item>view:first-child {
  151. color: #333333;
  152. }
  153. .home-list-item>view:first-child>view {
  154. margin-right: 10upx;
  155. font-size: 32upx;
  156. }
  157. .home-list-item>view:last-child {
  158. color: #CCCCCC;
  159. }
  160. .home-list-hover {
  161. background: #f4f4f4;
  162. }
  163. .rightText {
  164. font-size: 30upx;
  165. }
  166. .icon {
  167. margin-left: 10upx;
  168. font-size: 24upx;
  169. }
  170. </style>