金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
9.4 KiB

  1. <template>
  2. <view id="ordershare">
  3. <view class="header">
  4. <view class="statustxt">支付完成货物整装待发</view>
  5. <view class="infomation">
  6. <view class="item mar-r">
  7. <view class="title">昵称</view>
  8. <view class="text">{{info.accept_name}}</view>
  9. </view>
  10. <view class="item">
  11. <view class="title">手机号</view>
  12. <view class="text">{{info.mobile}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="goods-info">
  17. <view class="title mx-1px-bottom">
  18. <view>
  19. 商品信息
  20. </view>
  21. <view :data-id="info.items[0].item_meta.detail_id" class="buy" @tap="jumpDetail">
  22. 去购买
  23. </view>
  24. </view>
  25. <view class="middle-item mx-1px-bottom" :data-id="item.item_meta.detail_id" v-for="(item, index) in info.items" :key="index" @tap="jumpDetail">
  26. <image :src="item.item_meta.image"></image>
  27. <view class="text">
  28. <view class="names">
  29. {{item.item_name}}
  30. </view>
  31. <view class="model">
  32. {{item.item_meta.specs_text}}
  33. </view>
  34. </view>
  35. <view class="money-box">
  36. <view>
  37. {{item.quantity}}
  38. </view>
  39. <view>
  40. {{item.units_total_yuan}}
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="somebody" v-if="info.users_avatar && info.users_avatar.length">
  46. <view class="title mx-1px-bottom">还有这些朋友订购了这件商品</view>
  47. <view class="content">
  48. <view class="item-img" v-for="(item, index) in info.users_avatar" :key="index" >
  49. <image :src="item"></image>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="order-info">
  54. <view class="item mx-1px-bottom">
  55. <view class="title">下单时间</view>
  56. <view class="txt">{{info.submit_time}}</view>
  57. </view>
  58. <view class="item mx-1px-bottom">
  59. <view class="title">商品总数</view>
  60. <view class="txt">{{info.count}}</view>
  61. </view>
  62. <view class="item mx-1px-bottom">
  63. <view class="title">总价格</view>
  64. <view class="txt">¥ {{info.total_yuan}}</view>
  65. </view>
  66. <view class="item mx-1px-bottom">
  67. <view class="title">支付时间</view>
  68. <view class="txt">{{info.pay_time}}</view>
  69. </view>
  70. </view>
  71. <view class="call-goods" v-if="info.commend_goods && info.commend_goods.length">
  72. <view class="title mx-1px-bottom">
  73. 相关推荐
  74. </view>
  75. <view class="content">
  76. <view class="like_list">
  77. <view class="like_box" :data-id="item.id" v-for="(item, index) in info.commend_goods" :key="index" @tap="jumpDetail">
  78. <view>
  79. <view class="like_image">
  80. <image class="responsive" :src="item.img"></image>
  81. </view>
  82. <view class="like_name">
  83. {{item.name}}
  84. </view>
  85. <view class="like_money">
  86. {{item.sell_price}}
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- #ifdef APP-PLUS || MP-WEIXIN -->
  94. <view class="order-share" @tap="changeShare" v-if="info.is_share_order == 1">
  95. <view class="text" :style="'background: ' + config.mainColor">订单分享</view>
  96. </view>
  97. <!-- #endif -->
  98. <!-- #ifdef H5 -->
  99. <view class="order-share" @tap="togglePopup('middle-img')" v-if="info.is_share_order == 1">
  100. <view class="text" :style="'background: ' + config.mainColor">订单分享</view>
  101. </view>
  102. <!-- #endif -->
  103. <!--点击分享弹出层-->
  104. <!--弹出分享部分-->
  105. <view class="maks" :class="show_share ? 'cur' : ''" @tap="changeShare">
  106. </view>
  107. <view class="share-box" :class="show_share ? 'cur' : ''">
  108. <!-- #ifdef MP-WEIXIN -->
  109. <button class="shaer-item" open-type="share">
  110. 分享给好友
  111. </button>
  112. <!-- #endif -->
  113. <!-- #ifdef APP-PLUS -->
  114. <button class="shaer-item" @click="shareapp">
  115. 分享给好友
  116. </button>
  117. <!-- #endif -->
  118. <view class="shaer-item mx-1px-top" @tap="getShearImg">
  119. 生成海报
  120. </view>
  121. <view class="shaer-item clear" @tap="changeShare">
  122. 取消
  123. </view>
  124. </view>
  125. <!-- #ifdef H5 -->
  126. <view >
  127. <uni-popup :show="type === 'middle-img'" position="top" mode="fixed" @hidePopup="togglePopup('')">
  128. <view class="uni-center center-box">
  129. <image style="position: absolute; top: 0;right:0" @tap="togglePopup('')" class="image" src="/static/ico-share-wechat.png" />
  130. </view>
  131. </uni-popup>
  132. </view>
  133. <!-- #endif -->
  134. </view>
  135. </template>
  136. <script>
  137. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  138. export default {
  139. data() {
  140. return {
  141. show_share: false,
  142. info: '',
  143. is_order: true,
  144. order_no: '',
  145. config: '',
  146. type:0
  147. };
  148. },
  149. onLoad(e) {
  150. // 第三方平台配置颜色
  151. var bgConfig = this.$cookieStorage.get('globalConfig') || '';
  152. this.setData({
  153. config: bgConfig
  154. });
  155. var order_no = e.order_no;
  156. if (e.scene) {
  157. var scene = decodeURIComponent(e.scene);
  158. var sceneArr = scene.split(',');
  159. order_no = sceneArr[0];
  160. }
  161. this.setData({
  162. order_no: order_no
  163. });
  164. if (!e.is_order) {
  165. this.setData({
  166. is_order: false
  167. });
  168. }
  169. this.queryOrderInfo(order_no);
  170. },
  171. //分享给好友
  172. onShareAppMessage(res) {
  173. return {
  174. title: this.info.accept_name + this.info.share_order_title || '分享了一个订单',
  175. path: '/pages/order/orderShare/orderShare?order_no=' + this.order_no
  176. };
  177. },
  178. methods: {
  179. togglePopup(type) {
  180. this.type = type;
  181. },
  182. shareapp(){
  183. var accept_name = this.info.accept_name;
  184. var share_order_title = this.info.share_order_title;
  185. order_no = this.order_no;
  186. uni.getProvider({
  187. service:'share',
  188. success:function(res){
  189. uni.share({
  190. provider: "weixin",
  191. scene: "WXSceneSession",
  192. type: 5,
  193. title:accept_name + share_order_title,
  194. imageUrl:'https://cdn.guojiang.club/guojiang_logo.png',
  195. miniProgram:{
  196. id:'gh_72e65196278a',
  197. path:'pages/order/orderShare/orderShare?order_no=' + order_no,
  198. type:0,
  199. webUrl: 'https://guojiang.club'
  200. },
  201. success: function (res) {
  202. console.log("success:" + JSON.stringify(res));
  203. },
  204. fail: function (err) {
  205. console.log("fail:" + JSON.stringify(err));
  206. }
  207. });
  208. }
  209. })
  210. },
  211. changeShare() {
  212. this.setData({
  213. show_share: !this.show_share
  214. });
  215. },
  216. jumpDetail(e) {
  217. var id = e.currentTarget.dataset.id;
  218. wx.navigateTo({
  219. url: '/pages/store/detail/detail?id=' + id
  220. });
  221. },
  222. getShearImg() {
  223. wx.navigateTo({
  224. url: '/pages/order/shareImg/shareImg?order_no=' + this.order_no
  225. });
  226. },
  227. queryOrderInfo(order_no) {
  228. wx.showLoading({
  229. title: '加载中',
  230. mask: true
  231. });
  232. var token = this.$cookieStorage.get('user_token') || '';
  233. this.$http.ajax({
  234. method: this.is_order ? 'post' : 'get',
  235. api: 'api/order/' + order_no + '/share',
  236. header: {
  237. Authorization: token
  238. }
  239. }).then(res => {
  240. if (res.statusCode == 200) {
  241. res = res.data;
  242. if (res.status) {
  243. this.setData({
  244. info: res.data
  245. });
  246. if (res.data.is_share_order == 0) {
  247. wx.hideShareMenu();
  248. }
  249. // #ifdef H5
  250. if(res.data.is_share_order != 0){
  251. if (this.$wechat && this.$wechat.isWechat()) {
  252. var title = this.info.accept_name + this.info.share_order_title || '分享了一个订单'
  253. this.$wechat.share({
  254. title: title
  255. });
  256. }
  257. }
  258. // #endif
  259. } else {
  260. wx.showModal({
  261. content: res.message || '请求失败',
  262. showCancel: false
  263. });
  264. }
  265. } else {
  266. wx.showModal({
  267. content: '请求失败',
  268. showCancel: false
  269. });
  270. }
  271. wx.hideLoading();
  272. }).catch(() => {
  273. wx.hideLoading();
  274. wx.showModal({
  275. content: '请求失败',
  276. showCancel: false
  277. });
  278. });
  279. },
  280. setData: function (obj) {
  281. let that = this;
  282. let keys = [];
  283. let val, data;
  284. Object.keys(obj).forEach(function (key) {
  285. keys = key.split('.');
  286. val = obj[key];
  287. data = that.$data;
  288. keys.forEach(function (key2, index) {
  289. if (index + 1 == keys.length) {
  290. that.$set(data, key2, val);
  291. } else {
  292. if (!data[key2]) {
  293. that.$set(data, key2, {});
  294. }
  295. }
  296. data = data[key2];
  297. });
  298. });
  299. }
  300. },
  301. computed: {},
  302. watch: {}
  303. };
  304. </script>
  305. <style rel="stylesheet/less" lang="less">
  306. @import "orderShare";
  307. </style>