index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <view class="main" :style="colorStyle">
  3. <view class="head" v-if="!resData.type && !resData.paid">
  4. <view class="user-img">
  5. <image class="" :src="resData.avatar" mode=""></image>
  6. </view>
  7. <!-- paid: 0 未支付 1 已支付 type:0 本人 1 好友-->
  8. <view class="order-status" v-if="!resData.paid && !resData.type">
  9. {{$t(`代付订单创建成功,发给好友帮你付款吧~`)}}
  10. </view>
  11. </view>
  12. <view class="head-other" v-else>
  13. <view class="user-img">
  14. <image class=""
  15. :src="resData.paid && !resData.type && resData.pay_uid === $store.state.app.uid ? resData.pay_avatar : resData.avatar"
  16. mode="">
  17. </image>
  18. </view>
  19. <view class="order-status">
  20. <view class="head-other-nickname">
  21. {{resData.paid && !resData.type && resData.pay_uid === $store.state.app.uid ? resData.pay_nickname : resData.nickname}}
  22. </view>
  23. <view class="head-other-trip" v-if="!resData.paid && resData.type">
  24. {{$t(`帮我付一下这件商品了,谢谢~`)}}
  25. </view>
  26. <view class="head-other-trip"
  27. v-if="resData.pay_uid !== $store.state.app.uid && resData.paid && resData.type">
  28. {{$t(`已经有人替我代付,谢谢啦~`)}}
  29. </view>
  30. <view class="head-other-trip"
  31. v-if="resData.pay_uid === $store.state.app.uid && resData.paid && resData.type">
  32. {{$t(`谢谢你帮我支付,么么哒~`)}}
  33. </view>
  34. <view class="head-other-trip" v-if="resData.pay_uid !== resData.uid && resData.paid && !resData.type">
  35. {{$t(`我已为你代付成功,商家正在努力发货中~`)}}
  36. </view>
  37. </view>
  38. </view>
  39. <view class="order-msg">
  40. <view class="pay-success" v-if="resData.paid && !resData.type">
  41. {{$t(`好友代付成功,商家正在努力发货中~`)}}
  42. </view>
  43. <view v-else class="pay--box">
  44. <view class="order-top">
  45. {{$t(`代付金额`)}}
  46. </view>
  47. <view class="order-num">
  48. <text class="icon">{{$t(`¥`)}}</text>
  49. {{resData.pay_price || 0}}
  50. </view>
  51. </view>
  52. <!-- #ifdef APP-PLUS -->
  53. <view v-if="!resData.paid && !resData.type" class="order-btn" @click="appShare('WXSceneSession')">
  54. {{$t(`发送给微信好友`)}}
  55. </view>
  56. <!-- #endif -->
  57. <!-- #ifdef H5 -->
  58. <view v-if="!resData.paid && !resData.type" class="order-btn" @click="shareFriend">
  59. {{$t(`发送给微信好友`)}}
  60. </view>
  61. <!-- #endif -->
  62. <!-- #ifdef MP -->
  63. <button v-if="!resData.paid && !resData.type" class="order-btn" open-type="share" hover-class="none"
  64. @click="shareModal = false">
  65. {{$t(`发送给微信好友`)}}
  66. </button>
  67. <!-- #endif -->
  68. <button v-if="!resData.paid && !resData.type" class="order-btn detail" @click="goOrderDetail()">
  69. {{$t(`查看订单详情`)}}
  70. </button>
  71. <button class="order-btn" v-if="!resData.paid && resData.type" @tap='payOpen()'>{{$t(`立即付款`)}}</button>
  72. <button class="order-btn on-pay" v-if="resData.paid && resData.type">{{$t(`订单已支付`)}}</button>
  73. <button class="order-btn" v-if="resData.paid && !resData.type"
  74. @tap='goOrderDetail()'>{{$t(`查看订单详情`)}}</button>
  75. <view class="order-trip" v-if="resData.pay_uid === $store.state.app.uid && resData.type">
  76. {{$t(`如果订单申请退款,已支付金额将原路退还给您`)}}
  77. </view>
  78. </view>
  79. <view class="order-list">
  80. <orderGoods :cartInfo="resData.cartInfo" :is_confirm='true' :pay_price="resData.pay_price"
  81. :is_behalf="resData.paid && !resData.type ? true :false"></orderGoods>
  82. </view>
  83. <view class="share-box" v-if="shareModal">
  84. <image src="../static/share-info2.png" @click="shareModal = false"></image>
  85. </view>
  86. <payment :payMode='payMode' :pay_close="pay_close" :friendPay="true" @onChangeFun='onChangeFun'
  87. :order_id="order_id" :totalPrice='resData.pay_price'></payment>
  88. <!-- #ifndef MP -->
  89. <home></home>
  90. <!-- #endif -->
  91. </view>
  92. </template>
  93. <script>
  94. import orderGoods from '@/components/orderGoods';
  95. import colors from "@/mixins/color";
  96. import payment from '@/components/payment';
  97. import home from '@/components/home/index.vue'
  98. import {
  99. friendDetail
  100. } from '@/api/user.js'
  101. import {
  102. HTTP_REQUEST_URL
  103. } from "@/config/app.js";
  104. import {
  105. toLogin
  106. } from '@/libs/login.js';
  107. import {
  108. mapGetters
  109. } from "vuex";
  110. export default {
  111. mixins: [colors],
  112. components: {
  113. orderGoods,
  114. payment,
  115. home
  116. },
  117. computed: mapGetters(["isLogin"]),
  118. data() {
  119. return {
  120. shareModal: false,
  121. cartInfo: [],
  122. resData: {},
  123. payMode: [{
  124. name: this.$t(`微信支付`),
  125. icon: "icon-weixinzhifu",
  126. value: 'weixin',
  127. title: this.$t(`使用微信快捷支付`),
  128. payStatus: true,
  129. },
  130. // #ifdef H5 || APP-PLUS
  131. // {
  132. // name: '支付宝支付',
  133. // icon: 'icon-zhifubao',
  134. // value: 'alipay',
  135. // title: '使用线上支付宝支付',
  136. // payStatus: true
  137. // },
  138. // #endif
  139. ],
  140. pay_close: false,
  141. order_id: ''
  142. }
  143. },
  144. watch: {
  145. isLogin: {
  146. handler: function(newV, oldV) {
  147. if (newV == true) {
  148. this.getDetail()
  149. }
  150. },
  151. deep: true,
  152. },
  153. },
  154. onReady() {
  155. // uni.setNavigationBarTitle({
  156. // title: '好友代付' || '支付成功'
  157. // });
  158. },
  159. onLoad(option) {
  160. this.order_id = option.order_id
  161. },
  162. onShow() {
  163. if (this.isLogin) {
  164. this.getDetail()
  165. } else {
  166. toLogin();
  167. }
  168. },
  169. // #ifdef MP
  170. onShareAppMessage() {
  171. let that = this;
  172. return {
  173. title: "",
  174. imageUrl: "",
  175. path: "/pages/users/payment_on_behalf/index?order_id=" + that.order_id + "&spread=" + this.$store.state.app
  176. .uid,
  177. };
  178. },
  179. // #endif
  180. methods: {
  181. /**
  182. * 打开支付组件
  183. *
  184. */
  185. payOpen() {
  186. this.pay_close = true;
  187. },
  188. getDetail() {
  189. let that = this;
  190. friendDetail(this.order_id).then(res => {
  191. this.resData = res.data.info
  192. if (this.resData.paid && !this.resData.type) {
  193. this.goOrderDetail()
  194. }
  195. //#ifdef H5
  196. this.ShareInfo(this.resData)
  197. //#endif
  198. }).catch((err) => {
  199. that.$util.Tips({
  200. title: err
  201. }, {
  202. tab: 4,
  203. url: '/pages/index/index'
  204. });
  205. });
  206. },
  207. //#ifdef H5
  208. ShareInfo(data) {
  209. let href = location.href;
  210. if (this.$wechat.isWeixin()) {
  211. let configAppMessage = {
  212. desc: this.$t(`帮我付一下这件商品了,谢谢~`),
  213. title: this.$t(`好友代付`),
  214. link: href,
  215. imgUrl: data.avatar,
  216. };
  217. this.$wechat
  218. .wechatEvevt(
  219. [
  220. "updateAppMessageShareData",
  221. "updateTimelineShareData",
  222. "onMenuShareAppMessage",
  223. "onMenuShareTimeline",
  224. ],
  225. configAppMessage
  226. )
  227. .then((res) => {})
  228. .catch((err) => {});
  229. }
  230. },
  231. //#endif
  232. // #ifdef APP-PLUS
  233. appShare(scene) {
  234. let that = this;
  235. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  236. let curRoute = routes[routes.length - 1].$page.fullPath; // 获取当前页面路由,也就是最后一个打开的页面路由
  237. uni.share({
  238. provider: "weixin",
  239. scene: scene,
  240. type: 0,
  241. href: `${HTTP_REQUEST_URL}${curRoute}`,
  242. title: that.$t(`好友代付`),
  243. summary: that.$t(`帮我付一下这件商品了,谢谢~`),
  244. imageUrl: that.resData.paid && !that.resData.type && that.resData.pay_uid === that.$store.state
  245. .app.uid ? that.resData.pay_avatar : that.resData.avatar,
  246. success: function(res) {
  247. uni.showToast({
  248. title: that.$t(`分享成功`),
  249. icon: "success",
  250. duration: 2000,
  251. });
  252. },
  253. fail: function(err) {
  254. uni.showToast({
  255. title: that.$t(`分享失败`),
  256. icon: "none",
  257. duration: 2000,
  258. });
  259. },
  260. });
  261. },
  262. // #endif
  263. shareFriend() {
  264. // #ifndef MP
  265. this.shareModal = true;
  266. // #endif
  267. },
  268. /**
  269. * 事件回调
  270. *
  271. */
  272. onChangeFun(e) {
  273. let opt = e;
  274. let action = opt.action || null;
  275. let value = opt.value != undefined ? opt.value : null;
  276. (action && this[action]) && this[action](value);
  277. },
  278. /**
  279. * 关闭支付组件
  280. */
  281. payClose() {
  282. this.pay_close = false;
  283. },
  284. /**
  285. * 支付失败回调
  286. */
  287. pay_fail() {
  288. this.pay_close = false;
  289. },
  290. /**
  291. * 支付成功回调
  292. */
  293. pay_complete() {
  294. this.pay_close = false;
  295. this.getDetail();
  296. uni.navigateTo({
  297. url: '/pages/users/payment_on_behalf/pay_status?order_id=' + this.order_id
  298. })
  299. },
  300. goOrderDetail() {
  301. uni.navigateTo({
  302. url: '/pages/goods/order_details/index?order_id=' + this.order_id
  303. })
  304. }
  305. }
  306. }
  307. </script>
  308. <style lang="scss" scoped>
  309. .main {
  310. background-color: #f5f5f5;
  311. .head {
  312. background-color: var(--view-theme);
  313. display: flex;
  314. flex-direction: column;
  315. align-items: center;
  316. justify-content: center;
  317. padding: 60rpx 0 62rpx 0;
  318. .user-img {
  319. image {
  320. width: 68rpx;
  321. height: 68rpx;
  322. border-radius: 50%;
  323. }
  324. }
  325. .order-status {
  326. margin-top: 20rpx;
  327. font-size: 28rpx;
  328. color: #fff;
  329. }
  330. }
  331. .head-other {
  332. background-color: var(--view-theme);
  333. display: flex;
  334. align-items: center;
  335. padding: 60rpx 0 60rpx 30rpx;
  336. .user-img {
  337. display: flex;
  338. align-items: center;
  339. image {
  340. width: 100rpx;
  341. height: 100rpx;
  342. border-radius: 50%;
  343. }
  344. }
  345. .order-status {
  346. margin-left: 20rpx;
  347. color: #fff;
  348. display: flex;
  349. flex-direction: column;
  350. justify-content: space-between;
  351. height: 100rpx;
  352. position: relative;
  353. .head-other-nickname {
  354. font-size: 28rpx;
  355. }
  356. .head-other-trip {
  357. padding: 6rpx 13rpx;
  358. font-size: 26rpx;
  359. background-color: rgba(255, 255, 255, 0.2);
  360. border-radius: 6rpx;
  361. }
  362. .head-other-trip::after {
  363. content: "";
  364. width: 0rpx;
  365. height: 0rpx;
  366. border: 10rpx solid rgba(255, 255, 255, 0.2);
  367. border-bottom: 10rpx solid transparent;
  368. border-left: 10rpx solid transparent;
  369. border-top: 10rpx solid transparent;
  370. position: absolute;
  371. left: -20rpx;
  372. bottom: 15rpx;
  373. }
  374. }
  375. }
  376. .order-msg {
  377. background-color: #fff;
  378. border-radius: 14rpx 14rpx 0 0;
  379. display: flex;
  380. flex-direction: column;
  381. align-items: center;
  382. padding: 40rpx 0;
  383. margin: -30rpx 30rpx 0 30rpx;
  384. .pay--box {
  385. text-align: center;
  386. }
  387. .pay-success {
  388. font-size: 30rpx;
  389. color: #333;
  390. font-weight: bold;
  391. }
  392. .order-num {
  393. .icon {
  394. font-size: 30rpx;
  395. }
  396. font-size: 66rpx;
  397. color: #333;
  398. font-weight: bold;
  399. }
  400. .order-btn {
  401. width: 90%;
  402. background-color: var(--view-theme);
  403. border-radius: 80rpx;
  404. padding: 26rpx 0;
  405. color: #fff;
  406. font-size: 30rpx;
  407. text-align: center;
  408. margin-top: 60rpx;
  409. }
  410. .order-btn.detail {
  411. margin-top: 20rpx;
  412. color: var(--view-theme);
  413. background-color: #fff;
  414. border: 1px solid var(--view-theme);
  415. }
  416. .order-btn.on-pay {
  417. background-color: #ccc;
  418. }
  419. .order-trip {
  420. color: #999;
  421. font-size: 26rpx;
  422. margin-top: 32rpx;
  423. }
  424. }
  425. .order-list {
  426. margin: 30rpx;
  427. border-radius: 14rpx;
  428. overflow: hidden;
  429. .orderGoods {
  430. margin-top: 0;
  431. }
  432. }
  433. .share-box {
  434. z-index: 1000;
  435. position: fixed;
  436. left: 0;
  437. top: 0;
  438. width: 100%;
  439. height: 100%;
  440. image {
  441. width: 100%;
  442. height: 100%;
  443. }
  444. }
  445. }
  446. </style>