index.vue 11 KB

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