order-sharelogin.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="container login" v-if="isShareStatus">
  3. <view class="container-main clearfix">
  4. <view class="main-title">此订单包含如下商品:</view>
  5. <view class="main-list clearfix">
  6. <view class="main-list-item" v-for="(item, index) in productList" :key="index">
  7. <view class="item-image"> <image :src="item.image" mode="scaleToFill"></image> </view>
  8. <view class="item-mesage">
  9. <view class="item-name">{{ item.name }}</view>
  10. <view class="item-num"><text>X</text>{{ item.num }}</view>
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="container-footer" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  16. <view class="login-btn" v-if="btnState.isPay" @click.stop="btnConfirmPay">立即支付</view>
  17. <view class="login-sub">
  18. <view class="btn" @click.stop="goLogin(1)">账号登录查看</view>
  19. <view class="btn" @click.stop="goLogin(2)">使用分享码查看</view>
  20. </view>
  21. <view class="pay-statustext">
  22. <view class="pay-statustext-inner">
  23. <view class="pay-text">
  24. <text>使用账号登录支持确认订单和直接付款,使用分享码只支持查看订单,不能操作</text>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import authorize from '@/common/config/authorize.js'
  33. import wxLogin from '@/common/config/wxLogin.js'
  34. export default {
  35. data() {
  36. return {
  37. isIphoneX: this.$store.state.isIphoneX,
  38. imagePath: 'https://img.caimei365.com/group1/M00/03/83/Cmis214FbbCAQhKoAAKWfqqSIds292.png',
  39. shareCode: '', //获取用户登录的邀请码
  40. isUserInfo: false, //控制显示授权弹窗
  41. isShareStatus: false,
  42. productList: [],
  43. params: {
  44. code: '',
  45. iv: '',
  46. encryptedData: '',
  47. orderId: 0, //订单ID
  48. userId: 0, //机构用户ID
  49. serviceProviderId: 0 //协销ID
  50. },
  51. btnState: {
  52. isPay: false
  53. },
  54. mapStateArr: [{ label: 'isPay', val: [11, 12, 13, 21, 22, 23, 111], status: true }]
  55. }
  56. },
  57. onLoad(e) {
  58. console.log(e)
  59. this.params.shopOrderId = e.shopOrderId
  60. this.params.userId = e.userId
  61. if (e.serviceProviderId) {
  62. this.params.serviceProviderId = e.serviceProviderId
  63. }
  64. wxLogin.wxLoginAuthorize()
  65. this.initQueryUser()
  66. },
  67. methods: {
  68. async initQueryUser() {
  69. const getUserInfo = await authorize.getUserInfo('weixin')
  70. this.params.code = await authorize.getCode('weixin')
  71. this.params.iv = getUserInfo.iv
  72. this.params.encryptedData = getUserInfo.encryptedData
  73. this.OrderService.OrderShareCodeIdentity(this.params).then(response => {
  74. if (response.code == 0) {
  75. // 初始化订单商品数据
  76. console.log(response.msg)
  77. this.getOrderCommodityData()
  78. } else if (response.code == 1) {
  79. // 同为会所运营人员查看订单详情
  80. this.$api.navigateTo(
  81. `/pages/user/order/order-details?type=share&shopOrderId=${this.params.shopOrderId}`
  82. )
  83. } else if (response.code == 2) {
  84. // 协销查看分享订单
  85. this.$api.navigateTo(
  86. `/pages/seller/order/order-details?type=share&shopOrderId=${this.params.shopOrderId}&userId=${
  87. this.params.userId
  88. }`
  89. )
  90. } else if (response.code == 3) {
  91. // 游客第二次查看订单详情
  92. this.$api.redirectTo(
  93. `/pages/user/order/order-sharedetails?shopOrderId=${this.params.shopOrderId}&userId=${
  94. this.params.userId
  95. }`
  96. )
  97. } else {
  98. // 错误信息返回
  99. this.$util.modal('提示', response.msg, '确定', '', false, () => {})
  100. }
  101. })
  102. },
  103. getOrderCommodityData() {
  104. //查询订单商品信息s
  105. this.OrderService.OrderCommodityData({ shopOrderId: this.params.shopOrderId })
  106. .then(response => {
  107. const data = response.data
  108. this.productList = data.productList
  109. this.mapStateArr.forEach(el => {
  110. el.val.forEach(value => {
  111. if (!data.payButton && data.orderStatus === value) {
  112. this.btnState[el.label] = el.status
  113. }
  114. })
  115. })
  116. this.isShareStatus = true
  117. })
  118. .catch(error => {
  119. this.$util.msg(error.msg, 2000)
  120. })
  121. },
  122. goLogin(index) {
  123. switch (index) {
  124. case 1:
  125. this.$store.commit('setLoginType', 7)
  126. this.$store.commit('setLoginOrderId', this.params.orderId)
  127. this.$api.navigateTo('/pages/login/login')
  128. break
  129. case 2:
  130. this.$api.navigateTo(
  131. `/pages/user/order/orderShareLogin?shopOrderId=${this.params.shopOrderId}&userId=${
  132. this.params.userId
  133. }`
  134. )
  135. break
  136. }
  137. },
  138. btnConfirmPay() {
  139. //监听根据付款状态做操作
  140. this.OrderService.OrderPaymentValidation({ shopOrderId: this.params.shopOrderId })
  141. .then(response => {
  142. if (response.data.code == -1) {
  143. this.$util.modal('', '订单已申请全部退款,无需再付款!', '确定', '', false, () => {})
  144. } else {
  145. this.$api.navigateTo(`/pages/user/order/order-pay-list?shopOrderId=${this.params.shopOrderId}`)
  146. }
  147. })
  148. .catch(error => {
  149. this.$util.msg(error.msg, 2000)
  150. })
  151. }
  152. },
  153. onShow() {
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. .login {
  159. width: 100%;
  160. height: 100%;
  161. background: #f7f7f7;
  162. .model-warp.none {
  163. display: none;
  164. }
  165. .model-warp.show {
  166. display: block;
  167. }
  168. .container-main {
  169. width: 100%;
  170. height: auto;
  171. padding-top: 80rpx;
  172. padding-bottom: 352rpx;
  173. .main-title {
  174. width: 100%;
  175. height: 80rpx;
  176. padding: 0 20rpx;
  177. background-color: #f7f7f7;
  178. line-height: 80rpx;
  179. text-align: left;
  180. font-size: $font-size-30;
  181. color: #333;
  182. box-sizing: border-box;
  183. position: fixed;
  184. top: 0;
  185. left: 0;
  186. }
  187. .main-list {
  188. box-sizing: border-box;
  189. width: 100%;
  190. height: auto;
  191. background-color: #ffffff;
  192. .main-list-item {
  193. box-sizing: border-box;
  194. width: 100%;
  195. height: 200rpx;
  196. padding: 20rpx;
  197. border-bottom: 1px solid #f7f7f7;
  198. .item-image {
  199. width: 160rpx;
  200. height: 160rpx;
  201. float: left;
  202. image {
  203. width: 160rpx;
  204. height: 160rpx;
  205. display: block;
  206. }
  207. }
  208. .item-mesage {
  209. width: 530rpx;
  210. height: 160rpx;
  211. float: left;
  212. margin-left: 20rpx;
  213. .item-name {
  214. width: 100%;
  215. height: 84rpx;
  216. line-height: 42rpx;
  217. font-size: $font-size-28;
  218. color: #333333;
  219. text-align: justify;
  220. text-overflow: ellipsis;
  221. display: -webkit-box;
  222. word-break: break-all;
  223. -webkit-box-orient: vertical;
  224. -webkit-line-clamp: 2;
  225. overflow: hidden;
  226. }
  227. .item-num {
  228. width: 100%;
  229. height: 46rpx;
  230. line-height: 46rpx;
  231. margin-top: 30rpx;
  232. font-size: $font-size-28;
  233. color: #333333;
  234. text-align: left;
  235. text {
  236. font-size: $font-size-20;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. }
  243. .login-btn {
  244. width: 600rpx;
  245. height: 88rpx;
  246. font-size: $font-size-28;
  247. line-height: 88rpx;
  248. color: #ffffff;
  249. margin: 0 auto;
  250. margin-bottom: 24rpx;
  251. text-align: center;
  252. background: $btn-confirm;
  253. border-radius: 50rpx;
  254. }
  255. .login-sub {
  256. width: 600rpx;
  257. height: 88rpx;
  258. margin: 0 auto;
  259. margin-bottom: 24rpx;
  260. display: flex;
  261. .btn {
  262. flex: 1;
  263. width: 288rpx;
  264. height: 88rpx;
  265. box-sizing: border-box;
  266. border: 1px solid #b2b2b2;
  267. text-align: center;
  268. line-height: 88rpx;
  269. margin: 0 12rpx;
  270. font-size: $font-size-30;
  271. color: #333333;
  272. border-radius: 50rpx;
  273. }
  274. }
  275. .container-footer {
  276. box-sizing: border-box;
  277. width: 100%;
  278. height: auto;
  279. padding: 0 24rpx;
  280. padding-top: 24rpx;
  281. padding-bottom: 24rpx;
  282. background-color: #ffffff;
  283. position: fixed;
  284. bottom: 0;
  285. left: 0;
  286. }
  287. .pay-statustext {
  288. width: 100%;
  289. height: auto;
  290. float: left;
  291. .pay-statustext-inner {
  292. width: 600rpx;
  293. margin: 0 auto;
  294. .pay-text {
  295. width: 600rpx;
  296. height: 100%;
  297. float: left;
  298. line-height: 40rpx;
  299. font-size: $font-size-26;
  300. color: #fea785;
  301. text-align: justify;
  302. }
  303. }
  304. }
  305. }
  306. </style>