index.vue 11 KB

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