jump.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="jump-container">
  3. <view v-if="viewType === 'verification'">
  4. <JHeader tabbar="/" width="50" height="50" title="订单核销"></JHeader>
  5. <view v-if="orderInfo && orderInfo.orderId" style="margin-top: 40upx;">
  6. <ATFOrderInfo :data="orderInfo"></ATFOrderInfo>
  7. </view>
  8. <view style="margin-top: 50upx;">
  9. <tui-input v-model="code" label="核销码" placeholder="请输入核销码" disabled></tui-input>
  10. </view>
  11. <view>
  12. <tui-button
  13. margin="20upx 0 0 auto" type="green" width="260rpx" shape="circle"
  14. @click="handleVerification()"
  15. >
  16. 确认核销
  17. </tui-button>
  18. </view>
  19. </view>
  20. <view v-else>
  21. <tui-skeleton :preload-data="preloadData" style="z-index: 888;"></tui-skeleton>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import { T_STORAGE_KEY, T_NEW_BIND_TYPE, T_NEW_BIND_CODE, T_NEW_BIND_ID } from '../../constant'
  27. import { ANOTHER_TF_SETTLE } from '../../config'
  28. // import { checkBindApi, bindLastUserApi, bindServiceUserBindingApi, bindPartnerInviteApi, bindPartnerGroupApi, bindchangeActivityUserApi } from '../../api/xxx'
  29. import { bindDistributorSalesCustomerApi, getOrderDetailApi, updateSetHxCodeApi, bindPlatformRelationshipCodeApi, bindPlatformRelationshipShopApi, bindPlatformInfoCodeBindingApi } from '../../api/anotherTFInterface'
  30. import { getStorageKeyToken, jumpToOtherProject } from '../../utils'
  31. import { Encrypt } from '../../utils/secret'
  32. export default {
  33. name: 'Jump',
  34. components: {},
  35. props: {},
  36. data() {
  37. return {
  38. data: [],
  39. preloadData: [
  40. {
  41. 'id': '',
  42. 'dataset': {},
  43. 'left': 164.84375,
  44. 'right': 365,
  45. 'top': 20,
  46. 'bottom': 220,
  47. 'width': 200.15625,
  48. 'height': 19,
  49. 'skeletonType': 'rect'
  50. }, {
  51. 'id': '',
  52. 'dataset': {},
  53. 'left': 0,
  54. 'right': 375,
  55. 'top': 70,
  56. 'bottom': 187,
  57. 'width': 375,
  58. 'height': 187,
  59. 'skeletonType': 'fillet'
  60. }
  61. ],
  62. type: '',
  63. code: '',
  64. otherSideUserId: '',
  65. userId: '',
  66. userInfo: {},
  67. // 视图显示
  68. viewType: '',
  69. // verification的情况
  70. orderId: '',
  71. orderInfo: {}
  72. }
  73. },
  74. /**
  75. * 生命周期函数--监听页面加载
  76. */
  77. // eslint-disable-next-line complexity
  78. onLoad(options) {
  79. if (options.type) uni.setStorageSync(T_NEW_BIND_TYPE, options.type) || uni.setStorageSync(T_NEW_BIND_CODE, options.code || '') || uni.setStorageSync(T_NEW_BIND_ID, options.userId || '') // 有绑定id就进行存储,以防下面没登录跳到登录页
  80. if (!getStorageKeyToken()) return
  81. this.userInfo = uni.getStorageSync(T_STORAGE_KEY) || {}
  82. this.userId = this.userInfo.buyerUserId || ''
  83. if (this.userId && !options.type && uni.getStorageSync(T_NEW_BIND_TYPE)) { // 如果原先有绑定id,例如注册/重新登陆了然后跳回来(options没携带绑定id),则是存储里的绑定id
  84. this.type = uni.getStorageSync(T_NEW_BIND_TYPE) || ''
  85. this.code = uni.getStorageSync(T_NEW_BIND_CODE) || ''
  86. this.otherSideUserId = uni.getStorageSync(T_NEW_BIND_ID) || ''
  87. this.handleBusiness(true)
  88. } else if (this.userId && options.type) { // 请求路径上面直接有绑定id参数
  89. this.type = options.type || ''
  90. this.code = options.code || ''
  91. this.otherSideUserId = options.userId || ''
  92. this.handleBusiness(false)
  93. }
  94. },
  95. /**
  96. * 生命周期函数--监听页面初次渲染完成
  97. */
  98. onReady() { },
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide() { },
  108. /**
  109. * 生命周期函数--监听页面卸载
  110. */
  111. onUnload() { },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh() { },
  116. /**
  117. * 页面上拉触底事件的处理函数
  118. */
  119. onReachBottom() { },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage() { },
  124. methods: {
  125. // 业务逻辑
  126. async handleBusiness(isFromLogin) {
  127. console.log(isFromLogin)
  128. uni.removeStorageSync(T_NEW_BIND_TYPE)
  129. uni.removeStorageSync(T_NEW_BIND_CODE)
  130. uni.removeStorageSync(T_NEW_BIND_ID)
  131. if (this.type === 'nothing') {
  132. this.$switchTab('/')
  133. } else if (this.type === 'bindingSalesCustomer') { // 绑定分销关系,salesId分销员ID
  134. const shareType = Number(this.code.split('~')[0])
  135. const shopId = this.code.split('~')[1]
  136. const productId = this.code.split('~')[2]
  137. const skuId = this.code.split('~')[3]
  138. const salesId = this.code.split('~')[4]
  139. bindDistributorSalesCustomerApi({ shopId, distributorId: salesId })
  140. .then((res) => {
  141. this.$showToast('绑定成功', 'success')
  142. setTimeout(() => {
  143. if (shareType === 1) {
  144. uni.redirectTo({ url: `/another-tf/another-user/shop/shop-detail?storeId=${shopId}` })
  145. } else if (shareType === 2) {
  146. uni.redirectTo({ url: `/another-tf/another-serve/goodsDetails/index?shopId=${shopId}&productId=${productId}&skuId=${skuId}` })
  147. }
  148. }, 2000)
  149. })
  150. .catch((e) => {
  151. setTimeout(() => { this.$switchTab('/') }, 2000)
  152. })
  153. } else if (this.type === 'verification') {
  154. this.orderId = this.code.split('~')[0]
  155. console.log(this.code.split('~')[1])
  156. this.viewType = 'verification'
  157. getOrderDetailApi({
  158. orderId: this.orderId,
  159. noticeId: 0
  160. }).then(({ data }) => {
  161. this.orderInfo = data
  162. })
  163. } else if (this.type === 'invitation') {
  164. setTimeout(() => { this.$switchTab('/') }, 1000)
  165. } else if (this.type === 'toAnotherTFSettle') {
  166. const storageKeyToken = getStorageKeyToken()
  167. if (storageKeyToken) {
  168. setTimeout(() => {
  169. jumpToOtherProject(`${ANOTHER_TF_SETTLE}/#/?username=${this.userInfo.nickName}&user=${Encrypt(storageKeyToken)}`)
  170. }, 300)
  171. }
  172. } else if (this.type === 'bindingUser') {
  173. bindPlatformRelationshipCodeApi({ code: this.code })
  174. .then((res) => { this.$showToast('绑定成功', 'success') })
  175. .finally((e) => { setTimeout(() => { this.$switchTab('/') }, 2000) })
  176. } else if (this.type === 'bindingFranchisee') {
  177. bindPlatformRelationshipShopApi({ code: this.code })
  178. .then((res) => { this.$showToast('绑定成功', 'success') })
  179. .finally((e) => { setTimeout(() => { this.$switchTab('/') }, 2000) })
  180. } else if (this.type === 'bindingShop') {
  181. bindPlatformInfoCodeBindingApi({ phone: this.code, type: 1 })
  182. .then((res) => { this.$showToast('绑定成功', 'success') })
  183. .finally((e) => { setTimeout(() => { this.$switchTab('/') }, 2000) })
  184. } else if (this.type === 'bindingTeamMembers') { // 这里指团长和合伙人,其它还有会员、股东
  185. const storageKeyToken = getStorageKeyToken()
  186. if (storageKeyToken) {
  187. setTimeout(() => {
  188. jumpToOtherProject(`${ANOTHER_TF_SETTLE}/#/?username=${this.userInfo.nickName}&user=${Encrypt(storageKeyToken)}&code=${this.code}`)
  189. }, 300)
  190. }
  191. } else if (this.type === 'bindLastUser') { // 旧系统
  192. checkBindApi({ userId: this.userId })
  193. .then(() => {
  194. this.$showToast('已存在上级绑定')
  195. setTimeout(() => { this.$switchTab('/') }, 2000)
  196. })
  197. .catch(() => {
  198. uni.hideToast()
  199. bindLastUserApi({ userId: this.userId, userCode: this.code })
  200. .then((res) => { this.$showToast('绑定成功', 'success') })
  201. .finally((e) => { setTimeout(() => { this.$switchTab('/') }, 2000) })
  202. })
  203. } else if (this.type === 'bindCommunityService') { // 旧系统
  204. const serverTypeId = this.code.split('~')[0]
  205. const title = this.code.split('~')[1]
  206. const serverUrl = this.code.split('~')[2]
  207. bindServiceUserBindingApi({ bindingUserId: this.userId, shareUserId: this.otherSideUserId })
  208. .then((res) => { this.$showToast('成功参与服务分享!', 'success') })
  209. .finally((e) => { setTimeout(() => { uni.redirectTo({ url: `/community-center/community-detail?id=${serverTypeId}&serverNameThree=${title}&serverImageUrl=${serverUrl}` }) }, 2000) })
  210. } else if (this.type === 'bindPartnerInvite') { // 旧系统 // 师傅邀请码,用户绑定师傅
  211. bindPartnerInviteApi({ userId: this.userId, partnerCode: this.code })
  212. .then((data) => {
  213. if (data.ok) {
  214. this.$showToast('扫码成功', 'success')
  215. } else {
  216. this.$showToast(data.msg || '扫码失败', 'error')
  217. }
  218. })
  219. .catch((e) => { this.$showToast('操作失败,请重试', 'error') })
  220. .finally((e) => {
  221. setTimeout(() => {
  222. getApp().globalData.isShowFollowOfficialAccount = true
  223. uni.setStorageSync(xxx, this.code)
  224. this.$switchTab('/')
  225. }, 2000)
  226. })
  227. } else if (this.type === 'bindPartnerGroup') { // 旧系统 // 团长码,用户绑定团长
  228. bindPartnerGroupApi({ userId: this.userId, partnerCode: this.code })
  229. .then((data) => {
  230. if (data.ok) {
  231. this.$showToast('操作成功', 'success')
  232. } else {
  233. this.$showToast('操作失败,请重试', 'error')
  234. }
  235. })
  236. .catch((e) => { this.$showToast('操作失败,请重试', 'error') })
  237. .finally((e) => { setTimeout(() => { this.$switchTab('/') }, 2000) })
  238. } else if (this.type === 'bindActivityUser') { // 旧系统 // 活动码,399活动绑定
  239. const campaignsType = this.code.split('-')[0] * 1
  240. const bindActivityId = this.code.split('-')[1]
  241. bindchangeActivityUserApi({ userId: this.userId, userCode: bindActivityId, type: campaignsType })
  242. .then((res) => { this.$showToast('绑定成功', 'success') })
  243. .finally((e) => { setTimeout(() => { uni.redirectTo({ url: '/user/sever/activityCenter/index' }) }, 2000) })
  244. }
  245. },
  246. handleVerification() {
  247. updateSetHxCodeApi({ orderId: this.orderId, noticeId: 0 })
  248. .then((res) => { this.$showToast('核销成功', 'success') })
  249. .finally((e) => { setTimeout(() => { this.$switchTab('/') }, 2000) })
  250. }
  251. }
  252. }
  253. </script>
  254. <style lang="less" scoped>
  255. .jump-container {
  256. min-height: 100vh;
  257. padding: 46upx;
  258. box-sizing: border-box;
  259. }
  260. </style>