index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. <template>
  2. <div class="group-con">
  3. <div class="header acea-row row-between-wrapper">
  4. <!-- 拼团活动的信息 -->
  5. <div class="pictrue">
  6. <img :src="pinkT.picUrl" />
  7. </div>
  8. <div class="text">
  9. <div class="line1" v-text="activity.name" />
  10. <div class="money">
  11. <span class="num" v-text="fen2yuan(pinkT.combinationPrice) || 0"></span>
  12. <span class="team cart-color">{{ pinkT.userSize + '人拼' }}</span>
  13. </div>
  14. </div>
  15. <div v-if="status === 3" class="iconfont icon-pintuanshibai"></div>
  16. <div v-else-if="status === 2" class="iconfont icon-pintuanchenggong font-color-red"></div>
  17. </div>
  18. <div class="wrapper">
  19. <!-- 拼团进展:拼团中 -->
  20. <div class="title acea-row row-center-wrapper" v-if="status === 1">
  21. <div class="line"></div>
  22. <div class="name acea-row row-center-wrapper">
  23. 剩余
  24. <CountDown :bgColor="bgColor" :is-day="false" :tip-text="' '" :day-text="' '" :hour-text="' : '"
  25. :minute-text="' : '" :second-text="' '" :datatime="pinkT.expireTime / 1000"></CountDown>
  26. <span class="end">结束</span>
  27. </div>
  28. <div class="line"></div>
  29. </div>
  30. <!-- 拼团进展:拼团成功 -->
  31. <div class="tips font-color-red" v-if="status === 2">恭喜您拼团成功</div>
  32. <!-- 拼团进展:拼团失败 -->
  33. <div class="tips" v-else-if="status === 3">还差{{ count }}人,拼团失败</div>
  34. <!-- 拼团中的记录列表 -->
  35. <div class="tips font-color-red" v-else-if="status === 1">拼团中,还差{{ count }}人拼团成功</div>
  36. <!-- 当前拼团记录列表 -->
  37. <div class="list acea-row row-middle"
  38. :class="[status === 2 || status === 3 ? 'result' : '', iShidden ? 'on' : '']">
  39. <div class="pinkT">
  40. <div class="pictrue">
  41. <img :src="pinkT.avatar" />
  42. </div>
  43. <div class="chief">团长</div>
  44. </div>
  45. <block v-if="pinkAll.length > 0">
  46. <div class="pictrue" v-for="(item, index) in pinkAll" :key="item.id">
  47. <img :src="item.avatar" />
  48. </div>
  49. </block>
  50. <div class="pictrue" v-for="index in count">
  51. <img class="img-none" src="/static/images/vacancy.png" />
  52. </div>
  53. </div>
  54. <div v-if="(status === 2 || status === 3) && count > 9"
  55. class="lookAll acea-row row-center-wrapper"
  56. @click="lookAll">
  57. {{ iShidden ? '收起' : '查看全部' }}
  58. <span class="iconfont" :class="iShidden ? 'icon-xiangshang' : 'icon-xiangxia'" />
  59. </div>
  60. <!-- 拼团操作:邀请 -->
  61. <!-- #ifndef MP -->
  62. <div v-if="userBool === 1 && status === 1">
  63. <div class="teamBnt bg-color-red" @click="goPoster">邀请好友参团</div>
  64. </div>
  65. <!-- #endif -->
  66. <!-- #ifdef MP -->
  67. <button open-type="share" class="teamBnt bg-color-red" v-if="userBool === 1 && status === 1">邀请好友参团</button>
  68. <!-- #endif -->
  69. <!-- 拼团操作:过期 -->
  70. <div class="teamBnt bg-color-hui" v-if="status === 3">拼团已过期</div>
  71. <!-- 拼团操作:参团 -->
  72. <div class="teamBnt bg-color-red" v-else-if="userBool === 0 && count > 0 && status === 1" @click="openAttr">
  73. 我要参团
  74. </div>
  75. <!-- 拼团操作:再次开团 -->
  76. <div class="teamBnt bg-color-red" v-if="status === 2 || status === 3"
  77. @click="goDetail(activity.id)">再次开团</div>
  78. <!-- 拼团操作:再次开团 -->
  79. <div class="cancel" @click="getCombinationRemove" v-if="status === 1 && userBool === 1">
  80. <span class="iconfont icon-guanbi3" /> 取消开团
  81. </div>
  82. <!-- 拼团操作:查看订单 -->
  83. <div class="lookOrder" v-if="status === 2" @click="goOrder">
  84. 查看订单信息 <span class="iconfont icon-xiangyou" />
  85. </div>
  86. </div>
  87. <!-- 更多拼团 -->
  88. <div class="group-recommend">
  89. <div class="title acea-row row-between-wrapper">
  90. <div>大家都在拼</div>
  91. <div class="more" @click="goList">
  92. 更多拼团 <span class="iconfont icon-jiantou"></span>
  93. </div>
  94. </div>
  95. <div class="list acea-row row-middle">
  96. <div class="item" v-for="(item, index) in storeCombinationHost" :key="index" @click="goDetail(item.id)">
  97. <div class="pictrue">
  98. <img :src="item.picUrl" />
  99. <div class="team" v-text="(item.userSize) + '人团'"></div>
  100. </div>
  101. <div class="name line1" v-text="item.spuName"></div>
  102. <div class="money font-color-red" v-text="'¥' + fen2yuan(item.combinationPrice)"></div>
  103. </div>
  104. </div>
  105. </div>
  106. <!-- SKU 选择 -->
  107. <product-window
  108. :attr="attr"
  109. :iSbnt="1"
  110. @ChangeAttr="ChangeAttr"
  111. @ChangeCartNum="ChangeCartNum"
  112. @iptCartNum="iptCartNum"
  113. @close="closeAttr"
  114. @goCat="goPay"
  115. />
  116. <view class="mask" v-if="posters || canvasStatus" @click="listenerActionClose"></view>
  117. <!-- 发送给朋友图片 -->
  118. <view class="share-box" v-if="H5ShareBox">
  119. <image src="/static/images/share-info.png" @click="H5ShareBox = false"></image>
  120. </view>
  121. <!-- 海报展示 -->
  122. <view class='poster-pop' v-if="canvasStatus">
  123. <image :src='imagePath'></image>
  124. <!-- #ifndef H5 -->
  125. <view class='save-poster' @click="savePosterPath">保存到手机</view>
  126. <!-- #endif -->
  127. <!-- #ifdef H5 -->
  128. <view class="keep">长按图片保存至相册</view>
  129. <view class='iconfont icon-cha2 close' @tap='listenerActionClose'></view>
  130. <!-- #endif -->
  131. </view>
  132. <view class="canvas">
  133. <canvas style="width:597px;height:850px;" canvas-id="activityCanvas"></canvas>
  134. <canvas canvas-id="qrcode" :style="{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}"
  135. style="opacity: 0;" />
  136. </view>
  137. <home></home>
  138. </div>
  139. </template>
  140. <script>
  141. import CountDown from '@/components/countDown';
  142. import ProductWindow from '@/components/productWindow';
  143. import uQRCode from '@/js_sdk/Sansnn-uQRCode/uqrcode.js';
  144. import { imageBase64 } from "@/api/public";
  145. import { toLogin } from '@/libs/login.js';
  146. import { mapGetters } from 'vuex';
  147. import { postCombinationRemove } from '@/api/activity';
  148. import * as ProductSpuApi from '@/api/product/spu.js';
  149. import * as CombinationApi from '@/api/promotion/combination.js';
  150. import * as Util from '@/utils/util.js';
  151. import * as ProductUtil from '@/utils/product.js';
  152. import home from '@/components/home';
  153. const NAME = 'GroupRule';
  154. const app = getApp();
  155. export default {
  156. name: NAME,
  157. components: {
  158. CountDown,
  159. ProductWindow,
  160. home
  161. },
  162. props: {},
  163. data: function() {
  164. return {
  165. // ========== 拼团活动相关变量 ==========
  166. storeCombination: {}, //拼团产品
  167. activity: {}, // 拼团活动的信息
  168. bgColor: {
  169. 'bgColor': '#333333',
  170. 'Color': '#fff',
  171. 'width': '44rpx',
  172. 'timeTxtwidth': '16rpx',
  173. 'isDay': true
  174. },
  175. // ========== 拼团记录相关变量 ==========
  176. pinkId: 0, // 拼团记录编号
  177. pinkT: {}, // 团长信息
  178. pinkAll: [], // 团员列表
  179. count: 0, // 拼团剩余人数
  180. userBool: 0, // 判断当前用户是否在团内 | 0=未在,1=在
  181. status: 1, // 拼团记录的状态 | 1=进行中,2=已完成,3=未完成
  182. iShidden: false, // 拼团记录是否隐藏(查看全部、收齐)
  183. currentPinkOrder: '', // 当前用户的拼团订单
  184. timestamp: (new Date()).getTime(), // 当前时间戳
  185. // ========== 商品相关变量 ==========
  186. spu: {}, // 商品 SPU 详情
  187. skuMap: [], // 商品 SKU Map
  188. attrValue: '', // 已选属性名的拼接,例如说 红色,大 这样的格式
  189. attr: { // productWindow 组件,使用该属性
  190. cartAttr: false,
  191. // ↓↓↓ 属性数组,结构为:id = 属性编号;name = 属性编号的名字;values[].id = 属性值的编号,values[].name = 属性值的名字;index = 选中的属性值的名字
  192. productAttr: [],
  193. productSelect: {} // 选中的 SKU
  194. },
  195. // ========== 用户相关变量 ==========
  196. userInfo: {},
  197. // ========== 拼团推荐相关变量 ==========
  198. storeCombinationHost: [], // 拼团推荐
  199. // ========== 分销相关的变量 ==========
  200. qrcodeSize: 600, // 二维码的大小
  201. promotionCode: '', // 二维码图片
  202. imgTop: '', // 商品图片的 base64 码
  203. posters: false, // 分享弹窗的开关
  204. canvasStatus: false, // 是否显示海报
  205. H5ShareBox: false, // 公众号分享的弹出
  206. posterbackgd: '/static/images/canbj.png', // 海报的背景,用于海报的生成
  207. };
  208. },
  209. watch: {
  210. userData: {
  211. handler: function(newV, oldV) {
  212. if (newV) {
  213. this.userInfo = newV;
  214. app.globalData.openPages = '/pages/activity/goods_combination_status/index?id='
  215. + this.pinkId +
  216. "&spread=" + this.uid;
  217. }
  218. },
  219. deep: true
  220. }
  221. },
  222. computed: mapGetters({
  223. 'isLogin': 'isLogin',
  224. 'userData': 'userInfo',
  225. 'uid': 'uid'
  226. }),
  227. onLoad(options) {
  228. // 未登录,需要先去登录
  229. this.pinkId = options.id;
  230. if (!this.isLogin) {
  231. toLogin();
  232. }
  233. // TODO 芋艿:这里调用下加载 userinfo 信息,目前先写死;
  234. this.userInfo = {
  235. nickname: '芋艿'
  236. }
  237. // 加载拼团信息
  238. this.getCombinationPink();
  239. },
  240. //#ifdef MP
  241. /**
  242. * 用户点击右上角分享
  243. */
  244. onShareAppMessage: function() {
  245. return {
  246. title: '您的好友' + this.userInfo.nickname + '邀请您参团' + this.activity.name,
  247. path: app.globalData.openPages,
  248. imageUrl: this.pinkT.picUrl
  249. };
  250. },
  251. //#endif
  252. methods: {
  253. /**
  254. * 获得拼团记录
  255. */
  256. getCombinationPink: function() {
  257. CombinationApi.getCombinationRecordDetail(this.pinkId).then(res => {
  258. // 记录
  259. this.$set(this, 'pinkT', res.data.headRecord);
  260. this.$set(this, 'pinkAll', res.data.memberRecords);
  261. // 状态相关的字段
  262. this.$set(this, 'count', res.data.headRecord.userSize - res.data.headRecord.userCount);
  263. this.$set(this, 'userBool', res.data.orderId > 0 ? 1 : 0);
  264. this.$set(this, 'status', res.data.headRecord.status);
  265. this.$set(this, 'currentPinkOrder', res.data.orderId);
  266. // 加载拼团活动
  267. CombinationApi.getCombinationActivity(res.data.headRecord.activityId).then(res => {
  268. this.activity = res.data;
  269. // 获得商品详情
  270. this.getGoodsDetails();
  271. })
  272. // 加载更多拼团记录
  273. this.combinationMore();
  274. }).catch(err => {
  275. this.$util.Tips({
  276. title: err
  277. }, {
  278. url: '/pages/index/index'
  279. });
  280. });
  281. },
  282. /**
  283. * 前往订单
  284. */
  285. goOrder: function() {
  286. uni.navigateTo({
  287. url: '/pages/order_details/index?order_id=' + this.currentPinkOrder
  288. });
  289. },
  290. /**
  291. * 查看更多 / 收齐
  292. */
  293. lookAll: function() {
  294. this.iShidden = !this.iShidden;
  295. },
  296. // 拼团取消 TODO 芋艿
  297. getCombinationRemove: function() {
  298. var that = this;
  299. postCombinationRemove({
  300. id: that.pinkId
  301. }).then(res => {
  302. that.$util.Tips({
  303. title: res.msg
  304. }, {
  305. tab: 3
  306. });
  307. }).catch(res => {
  308. that.$util.Tips({
  309. title: res
  310. });
  311. });
  312. },
  313. // ========== 商品详情相关 ==========
  314. /**
  315. * 获取产品详情
  316. */
  317. getGoodsDetails: function() {
  318. ProductSpuApi.getSpuDetail(this.activity.spuId).then(res => {
  319. let spu = res.data;
  320. let skus = res.data.skus;
  321. this.$set(this, 'spu', spu);
  322. this.$set(this.attr, 'properties', ProductUtil.convertProductPropertyList(skus));
  323. this.$set(this, 'skuMap', ProductUtil.convertProductSkuMap(skus));
  324. // 将拼团活动的信息,合并到 SKU 里面,实现拼团价格的显示
  325. this.activity.products.forEach(product => {
  326. this.spu.price = Math.min(this.spu.price, product.combinationPrice); // 设置 SPU 的最低价格
  327. });
  328. skus.forEach(sku => {
  329. const product = this.activity.products.find(product => product.skuId === sku.id);
  330. if (product) {
  331. sku.price = product.combinationPrice;
  332. } else { // 找不到可能是没配置,则不能发起拼团
  333. sku.stock = 0;
  334. }
  335. // 设置限购数量
  336. if (this.activity.totalLimitCount > 0 && this.activity.singleLimitCount > 0) {
  337. sku.limitCount = Math.min(this.activity.totalLimitCount, this.activity.singleLimitCount);
  338. } else if (this.activity.totalLimitCount > 0) {
  339. sku.limitCount = this.activity.totalLimitCount;
  340. } else if (this.activity.singleLimitCount > 0) {
  341. sku.limitCount = this.activity.singleLimitCount;
  342. }
  343. });
  344. //#ifdef H5
  345. this.getImageBase64(spu.picUrl);
  346. this.make();
  347. this.setOpenShare();
  348. //#endif
  349. // 选中默认 sku
  350. this.selectDefaultSku();
  351. }).catch(err => {
  352. return this.$util.Tips({
  353. title: err.toString()
  354. }, {
  355. tab: 3,
  356. url: 1
  357. });
  358. })
  359. },
  360. /**
  361. * 默认选中属性
  362. */
  363. selectDefaultSku: function() {
  364. const properties = this.attr.properties;
  365. // 获得选中的属性值的名字,例如说 "黑色,大",则 skuKey = ["黑色", "大"]
  366. let skuKey = undefined;
  367. for (let key in this.skuMap) {
  368. if (this.skuMap[key].stock > 0) {
  369. skuKey = key.split(",");
  370. break;
  371. }
  372. }
  373. if (!skuKey) { // 如果找不到,则选中第一个
  374. skuKey = Object.keys(this.skuMap)[0].split(",");
  375. }
  376. // 使用 index 属性表示当前选中的,值为属性值的名字
  377. for (let i = 0; i < properties.length; i++) {
  378. this.$set(properties[i], "index", skuKey[i]);
  379. }
  380. let sku = this.skuMap[skuKey.join(",")];
  381. if (!sku) {
  382. return
  383. }
  384. this.$set(this.attr.productSelect, "spuName", this.spu.name);
  385. this.$set(this.attr.productSelect, "id", sku.id);
  386. this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
  387. this.$set(this.attr.productSelect, "price", sku.price);
  388. this.$set(this.attr.productSelect, "stock", sku.stock);
  389. this.$set(this.attr.productSelect, "cart_num", 1);
  390. this.$set(this.attr.productSelect, "limitCount", sku.limitCount); // 拼团活动特有字段
  391. this.$set(this, "attrValue", skuKey.join(","));
  392. },
  393. /**
  394. * 打开 SKU 属性的选择
  395. */
  396. openAttr: function() {
  397. this.$set(this.attr, 'cartAttr', true);
  398. },
  399. /**
  400. * 关闭 productWindow 弹窗
  401. */
  402. closeAttr: function() {
  403. this.$set(this.attr, 'cartAttr', false);
  404. },
  405. /**
  406. * 属性变动赋值
  407. *
  408. * @param newSkuKey 新的 skuKey
  409. * @param propertyIndex properties 的下标
  410. * @param valueIndex values 的下标
  411. */
  412. ChangeAttr: function(newSkuKey, propertyIndex, valueIndex) {
  413. // SKU
  414. let sku = this.skuMap[newSkuKey];
  415. if (!sku) {
  416. return;
  417. }
  418. this.$set(this.attr.productSelect, "id", sku.id);
  419. this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
  420. this.$set(this.attr.productSelect, "price", sku.price);
  421. this.$set(this.attr.productSelect, "stock", sku.stock);
  422. this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
  423. this.$set(this.attr.productSelect, "cart_num", 1);
  424. // SKU 关联属性
  425. this.$set(this.attr.properties[propertyIndex], 'index',
  426. this.attr.properties[propertyIndex].values[valueIndex].name);
  427. this.$set(this, "attrValue", newSkuKey);
  428. },
  429. /**
  430. * 购物车数量加和数量减
  431. *
  432. * @param changeValue true 增加;false 减少
  433. */
  434. ChangeCartNum: function(changeValue) {
  435. // 获取当前 sku
  436. let sku = this.attr.productSelect;
  437. if (!sku) {
  438. return;
  439. }
  440. // 设置数量
  441. let stock = sku.stock || 0;
  442. let limitCount = sku.limitCount;
  443. if (changeValue) {
  444. sku.cart_num++;
  445. if (limitCount > 0 && sku.cart_num > limitCount) {
  446. this.$set(this.attr.productSelect, "cart_num", limitCount);
  447. this.$util.Tips({
  448. title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
  449. });
  450. } else if (sku.cart_num > stock) {
  451. this.$set(this.attr.productSelect, "cart_num", stock);
  452. }
  453. } else {
  454. sku.cart_num--;
  455. if (sku.cart_num < 1) {
  456. this.$set(this.attr.productSelect, "cart_num", 1);
  457. }
  458. }
  459. },
  460. /**
  461. * 购物车手动填写
  462. *
  463. * @param number 数量
  464. */
  465. iptCartNum: function(number) {
  466. this.$set(this.attr.productSelect, 'cart_num', number ? number : 1);
  467. // 判断是否超限购
  468. let sku = this.attr.productSelect;
  469. let limitCount = sku.limitCount;
  470. if (limitCount > 0 && number > limitCount) {
  471. this.$set(this.attr.productSelect, "cart_num", limitCount);
  472. this.$util.Tips({
  473. title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
  474. });
  475. }
  476. },
  477. /**
  478. * 下订单
  479. */
  480. goPay() {
  481. let sku = this.attr.productSelect;
  482. uni.navigateTo({
  483. url: '/pages/users/order_confirm/index?skuId=' + sku.id + '&count=' + sku.cart_num
  484. + '&combinationActivityId=' + this.activity.id
  485. + '&combinationHeadId=' + this.pinkId
  486. });
  487. },
  488. /**
  489. * 拼团详情
  490. */
  491. goDetail: function(id) {
  492. uni.navigateTo({
  493. url: '/pages/activity/goods_combination_details/index?id=' + id
  494. });
  495. },
  496. // ========== 拼团推荐 ==========
  497. /**
  498. * 前往拼团列表
  499. */
  500. goList: function() {
  501. uni.navigateTo({
  502. url: '/pages/activity/goods_combination/index'
  503. });
  504. },
  505. /**
  506. * 更多拼团
  507. */
  508. combinationMore: function() {
  509. CombinationApi.getHeadCombinationRecordList(undefined, 1, 9).then(res => {
  510. this.storeCombinationHost = res.data;
  511. }).catch(res => {
  512. this.$util.Tips({
  513. title: res
  514. });
  515. })
  516. },
  517. // ========== 分销相关的方法 ==========
  518. /**
  519. * 生成二维码,设置到 promotionCode 变量
  520. */
  521. make() {
  522. let href = location.protocol + '//' + location.host +
  523. '/pages/activity/goods_combination_status/index?id=' + this.pinkId + "&spread=" + this.uid;
  524. uQRCode.make({
  525. canvasId: 'qrcode',
  526. text: href,
  527. size: this.qrcodeSize,
  528. margin: 10,
  529. success: res => {
  530. this.promotionCode = res;
  531. },
  532. fail: res => {
  533. this.$util.Tips({
  534. title: '海报二维码生成失败!'
  535. });
  536. }
  537. })
  538. },
  539. //#ifdef H5
  540. /**
  541. * 设置微信公众号的分享标题、内容等信息
  542. */
  543. setOpenShare() {
  544. // 只处理微信环境
  545. if (!this.$wechat.isWeixin()) {
  546. return
  547. }
  548. let configTimeline = {
  549. title: '您的好友' + this.userInfo.nickname + '邀请您参团' + this.spu.name,
  550. desc: this.spu.name,
  551. link: window.location.protocol + '//' + window.location.host +
  552. '/pages/activity/goods_combination_status/index?id=' + this.pinkId + "&spread=" + this.uid,
  553. imgUrl: this.spu.picUrl
  554. };
  555. this.$wechat.wechatEvevt([
  556. 'updateAppMessageShareData',
  557. 'updateTimelineShareData',
  558. 'onMenuShareAppMessage',
  559. 'onMenuShareTimeline'], configTimeline)
  560. .then(res => {
  561. console.log(res);
  562. }).catch(res => {
  563. if (res.is_ready) {
  564. res.wx.updateAppMessageShareData(configTimeline);
  565. res.wx.updateTimelineShareData(configTimeline);
  566. res.wx.onMenuShareAppMessage(configTimeline);
  567. res.wx.onMenuShareTimeline(configTimeline);
  568. }
  569. });
  570. },
  571. //#endif
  572. /**
  573. * 获得商品的封面 base64
  574. */
  575. getImageBase64: function(images) {
  576. imageBase64({
  577. url: images
  578. }).then(res => {
  579. this.imgTop = res.data.code;
  580. })
  581. },
  582. /**
  583. * 生成海报
  584. */
  585. goPoster: function() {
  586. //#ifdef H5
  587. if (this.$wechat.isWeixin()) {
  588. this.H5ShareBox = true;
  589. return
  590. }
  591. // 提示正在生成中
  592. uni.showLoading({
  593. title: '海报生成中',
  594. mask: true
  595. });
  596. this.posters = false;
  597. // 如果没有二维码图片,则说明加载失败,进行错误提示
  598. if (!this.promotionCode) {
  599. uni.hideLoading();
  600. this.$util.Tips({
  601. title: this.errT
  602. });
  603. return
  604. }
  605. // 校验海报是否已经生成;如果失败,则进行错误提示
  606. setTimeout(() => {
  607. if (!this.imgTop) {
  608. uni.hideLoading();
  609. this.$util.Tips({
  610. title: '无法生成商品海报!'
  611. });
  612. }
  613. }, 1000);
  614. // 展示海报
  615. let arrImagesUrlTop = '';
  616. uni.downloadFile({
  617. url: this.imgTop,
  618. success: (res) => {
  619. arrImagesUrlTop = res.tempFilePath;
  620. let arrImages = [this.posterbackgd, arrImagesUrlTop, this.promotionCode];
  621. const price = this.fen2yuan(this.pinkT.combinationPrice);
  622. setTimeout(() => {
  623. this.$util.activityCanvas(arrImages, this.spu.name,
  624. price, this.pinkT.userSize +
  625. '人团', '还差' + this.count + '人拼团成功', 9,
  626. (tempFilePath) => {
  627. this.imagePath = tempFilePath;
  628. this.canvasStatus = true;
  629. uni.hideLoading();
  630. });
  631. }, 500);
  632. }
  633. });
  634. //#endif
  635. },
  636. /**
  637. * 分享关闭
  638. */
  639. listenerActionClose: function() {
  640. this.posters = false;
  641. this.canvasStatus = false;
  642. },
  643. fen2yuan(price) {
  644. return Util.fen2yuan(price)
  645. }
  646. }
  647. };
  648. </script>
  649. <style lang="scss" scoped>
  650. .pinkT {
  651. position: relative;
  652. .chief {
  653. position: absolute;
  654. width: 72rpx;
  655. height: 30rpx;
  656. background-color: #E93323;
  657. border-radius: 15rpx;
  658. font-size: 20rpx;
  659. line-height: 30rpx;
  660. text-align: center;
  661. right: -24rpx;
  662. top: -16rpx;
  663. color: #fff;
  664. }
  665. }
  666. .canvas {
  667. position: fixed;
  668. opacity: 0;
  669. }
  670. .poster-pop {
  671. width: 594rpx;
  672. height: 850rpx;
  673. position: fixed;
  674. left: 50%;
  675. transform: translateX(-50%);
  676. z-index: 999;
  677. top: 50%;
  678. margin-top: -466rpx;
  679. image {
  680. width: 100%;
  681. height: 100%;
  682. display: block;
  683. border-radius: 10rpx;
  684. }
  685. .close {
  686. text-align: center;
  687. margin-top: 55rpx;
  688. color: #fff;
  689. font-size: 52rpx;
  690. }
  691. .save-poster {
  692. background-color: #df2d0a;
  693. font-size: :22rpx;
  694. color: #fff;
  695. text-align: center;
  696. height: 76rpx;
  697. line-height: 76rpx;
  698. width: 100%;
  699. }
  700. .keep {
  701. color: #fff;
  702. text-align: center;
  703. font-size: 25rpx;
  704. margin-top: 25rpx;
  705. }
  706. }
  707. /*开团*/
  708. .group-con .header {
  709. width: 100%;
  710. height: 186rpx;
  711. background-color: #fff;
  712. border-top: 1px solid #f5f5f5;
  713. padding: 0 30rpx;
  714. position: relative;
  715. }
  716. .group-con .header .iconfont {
  717. font-size: 100rpx;
  718. position: absolute;
  719. color: #ccc;
  720. right: 33rpx;
  721. bottom: 20rpx;
  722. }
  723. .group-con .header .pictrue {
  724. width: 140rpx;
  725. height: 140rpx;
  726. }
  727. .group-con .header .pictrue img {
  728. width: 100%;
  729. height: 100%;
  730. border-radius: 6rpx;
  731. }
  732. .group-con .header .text {
  733. width: 540rpx;
  734. font-size: 30rpx;
  735. color: #222;
  736. }
  737. .group-con .header .text .money {
  738. font-size: 24rpx;
  739. font-weight: bold;
  740. margin-top: 15rpx;
  741. }
  742. .group-con .header .text .money .num {
  743. font-size: 32rpx;
  744. }
  745. .group-con .header .text .money .team {
  746. padding: 1rpx 10rpx;
  747. font-weight: normal;
  748. border-radius: 50rpx;
  749. font-size: 20rpx;
  750. vertical-align: 4rpx;
  751. margin-left: 15rpx;
  752. }
  753. .group-con .wrapper {
  754. background-color: #fff;
  755. margin-top: 20rpx;
  756. padding: 2rpx 0 35rpx 0;
  757. }
  758. .group-con .wrapper .title {
  759. margin-top: 30rpx;
  760. }
  761. .group-con .wrapper .title .line {
  762. width: 136rpx;
  763. height: 1px;
  764. background-color: #ddd;
  765. }
  766. .group-con .wrapper .title .name {
  767. margin: 0 45rpx;
  768. font-size: 28rpx;
  769. color: #282828;
  770. }
  771. .group-con .wrapper .title .name .time {
  772. margin: 0 14rpx;
  773. }
  774. .group-con .wrapper .title .name .timeTxt {
  775. color: #fc4141;
  776. }
  777. .group-con .wrapper .title .name .time .styleAll {
  778. background-color: #ffcfcb;
  779. text-align: center;
  780. border-radius: 3rpx;
  781. font-size: 28rpx;
  782. font-weight: bold;
  783. display: inline-block;
  784. vertical-align: middle;
  785. color: #fc4141;
  786. padding: 2rpx 5rpx;
  787. }
  788. .group-con .wrapper .tips {
  789. font-size: 30rpx;
  790. font-weight: bold;
  791. text-align: center;
  792. margin-top: 30rpx;
  793. color: #999;
  794. }
  795. .group-con .wrapper .list {
  796. padding: 0 30rpx;
  797. margin-top: 45rpx;
  798. }
  799. .group-con .wrapper .list.result {
  800. max-height: 240rpx;
  801. }
  802. .group-con .wrapper .list.result.on {
  803. max-height: 2000rpx;
  804. }
  805. .group-con .wrapper .list .pictrue {
  806. width: 94rpx;
  807. height: 94rpx;
  808. margin: 0 0 29rpx 35rpx;
  809. }
  810. .group-con .wrapper .list .pictrue img {
  811. width: 100%;
  812. height: 100%;
  813. border-radius: 50%;
  814. border: 2rpx solid #e93323;
  815. }
  816. .group-con .wrapper .list .pictrue img.img-none {
  817. border: none;
  818. }
  819. .group-con .wrapper .lookAll {
  820. font-size: 24rpx;
  821. color: #282828;
  822. padding-top: 10rpx;
  823. }
  824. .group-con .wrapper .lookAll .iconfont {
  825. font-size: 25rpx;
  826. margin: 2rpx 0 0 10rpx;
  827. }
  828. .group-con .wrapper .teamBnt {
  829. font-size: 30rpx;
  830. width: 620rpx;
  831. height: 86rpx;
  832. border-radius: 50rpx;
  833. text-align: center;
  834. line-height: 86rpx;
  835. color: #fff;
  836. margin: 21rpx auto 0 auto;
  837. }
  838. .group-con .wrapper .cancel,
  839. .group-con .wrapper .lookOrder {
  840. text-align: center;
  841. font-size: 24rpx;
  842. color: #282828;
  843. padding-top: 30rpx;
  844. }
  845. .group-con .wrapper .cancel .iconfont {
  846. font-size: 35rpx;
  847. color: #2c2c2c;
  848. vertical-align: -4rpx;
  849. margin-right: 9rpx;
  850. }
  851. .group-con .wrapper .lookOrder .iconfont {
  852. font-size: 25rpx;
  853. color: #2c2c2c;
  854. margin-left: 10rpx;
  855. }
  856. .group-con .group-recommend {
  857. background-color: #fff;
  858. margin-top: 25rpx;
  859. }
  860. .group-con .group-recommend .title {
  861. padding-right: 30rpx;
  862. margin-left: 30rpx;
  863. height: 85rpx;
  864. border-bottom: 1px solid #eee;
  865. font-size: 28rpx;
  866. color: #282828;
  867. }
  868. .group-con .group-recommend .title .more {
  869. color: #808080;
  870. }
  871. .group-con .group-recommend .title .more .iconfont {
  872. margin-left: 13rpx;
  873. font-size: 28rpx;
  874. }
  875. .group-con .group-recommend .list {
  876. margin-top: 30rpx;
  877. }
  878. .group-con .group-recommend .list .item {
  879. width: 210rpx;
  880. margin: 0 0 25rpx 30rpx;
  881. }
  882. .group-con .group-recommend .list .item .pictrue {
  883. width: 100%;
  884. height: 210rpx;
  885. position: relative;
  886. }
  887. .group-con .group-recommend .list .item .pictrue img {
  888. width: 100%;
  889. height: 100%;
  890. border-radius: 10rpx;
  891. }
  892. .group-con .group-recommend .list .item .pictrue .team {
  893. position: absolute;
  894. top: 28rpx;
  895. left: -5rpx;
  896. min-width: 100rpx;
  897. height: 36rpx;
  898. line-height: 36rpx;
  899. text-align: center;
  900. border-radius: 0 18rpx 18rpx 0;
  901. font-size: 20rpx;
  902. color: #fff;
  903. background-image: linear-gradient(to right, #fb5445 0%, #e93323 100%);
  904. background-image: -webkit-linear-gradient(to right, #fb5445 0%, #e93323 100%);
  905. background-image: -moz-linear-gradient(to right, #fb5445 0%, #e93323 100%);
  906. }
  907. .group-con .group-recommend .list .item .name {
  908. font-size: 28rpx;
  909. color: #333;
  910. margin-top: 0.18rem;
  911. }
  912. .group-con .group-recommend .list .item .money {
  913. font-weight: bold;
  914. font-size: 28rpx;
  915. }
  916. .share-box {
  917. z-index: 1000;
  918. position: fixed;
  919. left: 0;
  920. top: 0;
  921. width: 100%;
  922. height: 100%;
  923. image {
  924. width: 100%;
  925. height: 100%;
  926. }
  927. }
  928. </style>