user.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="user-page-container">
  3. <TuanAppShim bg="#f6eadf"></TuanAppShim>
  4. <BaseInfo ref="baseInfoRef" @handleNavigate="handleNavigate"></BaseInfo>
  5. <view class="main-area">
  6. <Pane title="我的功能" :menu-data="myFunction" @menu-click="handleNavigate"></Pane>
  7. <Pane title="我的服务" :menu-data="myServe" @menu-click="handleNavigate"></Pane>
  8. <Pane title="商家服务" :menu-data="shopServe" @menu-click="handleNavigate"></Pane>
  9. <Pane title="附加功能" :menu-data="additionalFunction" @menu-click="handleNavigate"></Pane>
  10. <Pane title="我的优惠" :menu-data="myPreferential" @menu-click="handleNavigate"></Pane>
  11. <view>
  12. <Pane v-if="isShowOther" title="其它功能" :menu-data="otherFunction" @menu-click="handleNavigate"></Pane>
  13. <view v-else style="margin-top: 24upx;" @click="isShowOther = true">
  14. <view style="width: 632upx;height: 12upx;margin: 0 auto;background-color: #f1f1ef;"></view>
  15. </view>
  16. </view>
  17. </view>
  18. <tui-modal
  19. :show="$data._isShowTuiModel"
  20. title="提示"
  21. content="您还未登录,是否先去登录?"
  22. @click="_handleClickTuiModel($event, 'login', '/pages/user/user')"
  23. ></tui-modal>
  24. <tui-toast ref="toast"></tui-toast>
  25. <!-- 特殊code的 menu 操作 -->
  26. <CodeCreatePopup ref="codeCreateRef"></CodeCreatePopup>
  27. </view>
  28. </template>
  29. <script>
  30. import { getStorageKeyToken, jumpToOtherProject } from '../../utils'
  31. import BaseInfo from './cpns/BaseInfo'
  32. import Pane from './cpns/Pane.vue'
  33. import showModalMixin from '../../mixin/showModal'
  34. import { T_STORAGE_KEY } from '../../constant'
  35. import { myFunction, myServe, additionalFunction, shopServe, myPreferential, otherFunction } from './data'
  36. import { Encrypt } from '../../utils/secret'
  37. export default {
  38. name: 'User',
  39. components: {
  40. BaseInfo,
  41. Pane
  42. },
  43. mixins: [ showModalMixin() ],
  44. onShow() {
  45. this.init()
  46. },
  47. data() {
  48. return {
  49. timer: null,
  50. myFunction,
  51. myServe,
  52. shopServe,
  53. additionalFunction,
  54. myPreferential,
  55. otherFunction,
  56. isShowOther: false,
  57. userInfo: {},
  58. bindingCode: ''
  59. }
  60. },
  61. methods: {
  62. init() {
  63. this.userInfo = uni.getStorageSync(T_STORAGE_KEY) || {}
  64. if (this.isLogin()) {
  65. this.$refs.baseInfoRef && this.$refs.baseInfoRef.userIsPurchase()
  66. this.$store.dispatch('auth/refrshUserInfoAction')
  67. this.$store.dispatch('user/count')
  68. }
  69. this.$forceUpdate()
  70. },
  71. handleNavigate(item, cb) {
  72. if (item.navigate) {
  73. item.navigate()
  74. return
  75. }
  76. if (item.type === 'external') {
  77. this.go('/user/view?target=' + item.url)
  78. return
  79. }
  80. if (this.isLogin()) {
  81. if (item.type === 'userInvitation') {
  82. if (this.$store.state.auth.identityInfo.type.includes(1)) {
  83. uni.showActionSheet({
  84. title: '* 请选择业务 *',
  85. itemList: ['关系链绑定', '绑定加盟商'],
  86. itemColor: '#2c3e50',
  87. success: (res) => {
  88. if (res.tapIndex === 0) {
  89. this.$refs.codeCreateRef.getCode('userInvitation')
  90. } else if (res.tapIndex === 1) {
  91. this.$refs.codeCreateRef.getCode('franchiseeInvitation')
  92. }
  93. }
  94. })
  95. } else {
  96. this.$refs.codeCreateRef.getCode('userInvitation')
  97. }
  98. return
  99. } else if (item.type === 'flyToService') {
  100. this.$store.dispatch('app/getCustomerServiceAction', {
  101. isToService: true
  102. // shopId: this.$store.state.app.platformOperationShopId
  103. })
  104. return
  105. } else if (item.type === 'settle') {
  106. const storageKeyToken = getStorageKeyToken()
  107. if (storageKeyToken) {
  108. jumpToOtherProject(`${item.url}/#/?username=${this.userInfo.name}&user=${Encrypt(storageKeyToken)}`)
  109. }
  110. return
  111. } else if (item.type === 'shopInvitation') {
  112. this.$refs.codeCreateRef.getCode('shopInvitation')
  113. return
  114. }
  115. if (!item.url) {
  116. this.empty()
  117. return
  118. }
  119. if (cb && typeof cb === 'function' && cb()) {
  120. uni.navigateTo({
  121. url: item.url
  122. })
  123. } else {
  124. uni.navigateTo({
  125. url: item.url
  126. })
  127. }
  128. } else {
  129. this.$data._isShowTuiModel = true
  130. }
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="less" scoped>
  136. .user-page-container {
  137. widows: 100vw;
  138. min-height: 100vh;
  139. background-color: #f6f6f5;
  140. padding-bottom: 120upx;
  141. .main-area {
  142. width: 100%;
  143. padding: 0 32upx 32upx;
  144. box-sizing: border-box;
  145. /deep/ .menu-title {
  146. font-size: 24upx;
  147. color: #3a3629;
  148. }
  149. /deep/ .menu-icon {
  150. width: 64upx;
  151. height: 64upx;
  152. }
  153. /deep/ .menu-item {
  154. display: flex;
  155. align-items: center;
  156. justify-content: center;
  157. flex-direction: column;
  158. }
  159. /deep/ .order-pane {
  160. margin-top: 20upx;
  161. }
  162. }
  163. }
  164. /deep/ .tui-loading-init {
  165. position: inherit;
  166. transform: translate(0, 0);
  167. background-color: transparent;
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. width: 100vw;
  172. min-width: 100vw;
  173. max-width: 100vw;
  174. flex-direction: row;
  175. // padding-top: 30upx;
  176. }
  177. /deep/ .tui-loadmore-tips {
  178. color: #ff7a4e;
  179. margin-bottom: 40upx;
  180. }
  181. /deep/ .tui-loading-center {
  182. border-color: #ff7a4e;
  183. }
  184. </style>