app-group-avatar-short.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="app-group-avatar-short">
  3. <image class="app-background" mode="scaleToFill" src="/plugins/pt/image/group-avatar-BG.png"></image>
  4. <view class="app-background-image">
  5. <view class="app-text" >
  6. <template v-if="status === '1'">
  7. <text class="app-people">
  8. 还差
  9. <text class="app-num">{{surplus_people}}</text>
  10. 人,仅剩
  11. <text class="app-num">{{html}}</text>
  12. 失效
  13. </text>
  14. </template>
  15. <template v-else-if="status === '3' || status == 4">
  16. <text class="app-people">
  17. 超过有效时间,
  18. <text class="app-num">
  19. 拼团失败
  20. </text>
  21. </text>
  22. </template>
  23. <template v-else-if="status === '2'">
  24. <text class="app-people">
  25. 已成团
  26. </text>
  27. </template>
  28. </view>
  29. <view class="app-content dir-left-wrap main-center">
  30. <template v-if="status === '1' || status === '2'">
  31. <view class="app-item app-add" v-for="(item, index) in group_users" :key="index">
  32. <image lazy-load class="app-avatar app-add-avatar" :src="item.avatar"></image>
  33. <view class="app-name" v-if="item.is_parent == 1">团长</view>
  34. </view>
  35. </template>
  36. <block v-for="(item, index) in userList" :key="index">
  37. <view class="app-item app-no">
  38. <image class="app-avatar" src="/plugins/pt/image/question.png"></image>
  39. </view>
  40. </block>
  41. </view>
  42. </view>
  43. <view class="app-share" :class="theme + '-m-back ' + theme" v-if="status === '1' && is_join === '1'">
  44. <app-form-id @click="shareShow=true">
  45. 邀请好友
  46. </app-form-id>
  47. </view>
  48. <view class="app-share" :class="theme + '-m-back ' + theme" v-if="status === '1' && is_join === '0'" >
  49. <app-form-id @click="setShow">
  50. 我要参团
  51. </app-form-id>
  52. </view>
  53. <view class="app-share" :class="theme + '-m-back ' + theme" v-if="status === '2' && is_join === '1'">
  54. <app-form-id @click="shareShow=true">
  55. 分享给好友
  56. </app-form-id>
  57. </view>
  58. <view class="app-share" :class="theme + '-m-back ' + theme" v-if="status === '2' && is_join === '0'">
  59. <app-jump-button :url="`/plugins/pt/goods/goods?goods_id=${one_goods_id}`">
  60. 一键开团
  61. </app-jump-button>
  62. </view>
  63. <view class="app-share" :class="theme + '-m-back ' + theme" v-if="status === '3' || status == 4">
  64. <app-jump-button :url="`/plugins/pt/goods/goods?goods_id=${one_goods_id}`">
  65. 一键开团
  66. </app-jump-button>
  67. </view>
  68. <view>
  69. <app-share-qr-code :theme="theme"
  70. v-model="shareShow"
  71. :url="url"
  72. :poster-config="posterConfig"
  73. :poster-generate="posterGenerate"
  74. :has-poster-nav="hasPosterNav"
  75. ></app-share-qr-code>
  76. </view>
  77. <app-attr
  78. :selectAttr="selectAttr"
  79. :show="show"
  80. @attrtap="attrTap"
  81. @attr="setAttr"
  82. :attrGroupList="goods.attr_groups"
  83. :goods="goods"
  84. :theme="theme"
  85. >
  86. <view slot="extra" :style="{bottom: `${getEmpty}rpx`}" class="buy-btn cross-center main-center" :class="theme + '-m-back ' + theme" @click="buySubmit"
  87. v-if="attr.display === 'block'">确认</view>
  88. </app-attr>
  89. </view>
  90. </template>
  91. <script>
  92. import {mapGetters} from "vuex";
  93. import appShareQrCode
  94. from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  95. import appAttr from '../../../components/page-component/app-attr/app-attr.vue';
  96. export default {
  97. name: 'app-group-avatar-short',
  98. props: {
  99. surplus_people: Number,
  100. group_users: Array,
  101. surplusDateTime: String,
  102. url: String,
  103. status: String,
  104. goodsId: String,
  105. one_goods_id: Number,
  106. is_join: String,
  107. detail: Object,
  108. theme: String,
  109. posterConfig: String,
  110. posterGenerate: String,
  111. hasPosterNav: {
  112. type: Boolean,
  113. default() {
  114. return false
  115. },
  116. },
  117. },
  118. data() {
  119. return {
  120. time: null,
  121. html: '',
  122. shareShow: false,
  123. attr: {},
  124. selectAttr: {},
  125. show: 0,
  126. goods: {},
  127. userList: [],
  128. }
  129. },
  130. destroyed() {
  131. clearInterval(this.time);
  132. },
  133. methods: {
  134. setShow() {
  135. uni.showLoading();
  136. this.$request({
  137. url: this.$api.pt.detail,
  138. data: {
  139. id: this.goodsId,
  140. group_id: this.detail.group_id,
  141. }
  142. }).then(response => {
  143. uni.hideLoading();
  144. if (response.code === 0) {
  145. this.show = Math.random();
  146. this.goods = response.data.detail;
  147. } else {
  148. uni.showModal({
  149. content: response.msg,
  150. showCancel: false
  151. });
  152. }
  153. }).catch(e => {
  154. uni.hideLoading();
  155. })
  156. },
  157. setAttr(data) {
  158. this.attr = data;
  159. },
  160. setTime(v) {
  161. let timelog = new Date(v.replace(/-/g, '/'));
  162. clearInterval(this.time);
  163. this.time = setInterval(() =>{
  164. let time = timelog.getTime() - new Date().getTime();
  165. if (time < 0) {
  166. clearInterval(this.time);
  167. }
  168. let day = parseInt((time/1000/60/60/24)%30);
  169. let hou = parseInt((time/1000/60/60)%24);
  170. let min = parseInt((time/1000/60)%60);
  171. let sec = parseInt((time/1000)%60);
  172. if (day > 0) {
  173. this.html = day+"天"+hou+":"+(min<10?"0"+min:min) + ":"+(sec<10?"0"+sec:sec);
  174. } else {
  175. this.html = hou+":"+(min<10?"0"+min:min) + ":"+(sec<10?"0"+sec:sec);
  176. }
  177. },1000);
  178. },
  179. attrTap(data) {
  180. if (data !== null) {
  181. this.selectAttr = data;
  182. } else {
  183. this.selectAttr = {};
  184. }
  185. },
  186. buySubmit() {
  187. if (Object.keys(this.selectAttr).length === 0) {
  188. uni.showModal({
  189. title: '提示',
  190. content: '请先选择规格',
  191. showCancel: false
  192. });
  193. } else {
  194. let mch_id = this.goods.mch_id;
  195. let mch_list = [];
  196. let goods = {
  197. id: this.goods.id,
  198. attr: [],
  199. num: this.attr.number,
  200. goods_attr_id: this.selectAttr.id,
  201. cart_id: 0,
  202. };
  203. for (let i = 0; i < this.selectAttr.attr_list.length; i++) {
  204. let attr = {
  205. attr_id: this.selectAttr.attr_list[i].attr_id,
  206. attr_group_id: this.selectAttr.attr_list[i].attr_group_id,
  207. };
  208. goods.attr.push(attr);
  209. }
  210. mch_list.push({
  211. mch_id: mch_id,
  212. pintuan_order_id: this.detail.id,
  213. pintuan_group_id: this.detail.group_id,
  214. goods_list: [goods],
  215. });
  216. this.$jump({
  217. open_type: 'navigate',
  218. url: `/pages/order-submit/order-submit?mch_list=${JSON.stringify(mch_list)}&preview_url=${encodeURIComponent(this.$api.pt.order_preview)}&submit_url=${encodeURIComponent(this.$api.pt.order_submit)}&order_page_url=/plugins/pt/order/order&plugin=pt`
  219. });
  220. }
  221. },
  222. arr(data) {
  223. let ar = [];
  224. for (let i = 0; i < data; i++) {
  225. ar.push(i);
  226. }
  227. return ar;
  228. }
  229. },
  230. watch: {
  231. surplusDateTime: {
  232. handler: function(v) {
  233. this.setTime(v);
  234. },
  235. immediate: true
  236. },
  237. status: {
  238. handler: function(v) {
  239. if (Number(v) === 3) {
  240. this.userList = this.arr(this.orderRelation.length + this.surplus_people);
  241. } else if (Number(v) === 1) {
  242. this.userList = this.arr(this.surplus_people);
  243. } else {
  244. this.userList = this.arr(this.surplus_people);
  245. }
  246. },
  247. immediate: true
  248. }
  249. },
  250. computed: {
  251. ...mapGetters('iPhoneX',{
  252. getEmpty: 'getEmpty',
  253. })
  254. },
  255. components: {
  256. 'app-share-qr-code': appShareQrCode,
  257. 'app-attr': appAttr,
  258. }
  259. }
  260. </script>
  261. <style scoped lang="scss">
  262. .app-group-avatar-short {
  263. background-color: #f7f7f7;
  264. padding: #{10rpx} #{24rpx};
  265. box-sizing: border-box;
  266. min-height: #{230+24+88+32rpx};
  267. position: relative;
  268. .app-background {
  269. position: absolute;
  270. width: #{702rpx};
  271. height: #{220rpx};
  272. z-index: 0;
  273. top: 0;
  274. transform: translateX(-50%);
  275. left: 50%;
  276. margin-top: #{10rpx};
  277. }
  278. .app-background-image {
  279. width: #{702rpx};
  280. min-height: #{230-10rpx};
  281. padding-top: #{42rpx};
  282. box-sizing: border-box;
  283. .app-text {
  284. font-size: #{25rpx};
  285. text-align: center;
  286. margin-bottom: #{32rpx};
  287. z-index: 1000;
  288. position: relative;
  289. .app-people {
  290. color: #1b1b1b;
  291. .app-num {
  292. color: #ff2755;
  293. display: inline-block;
  294. margin: 0 #{10rpx};
  295. }
  296. }
  297. }
  298. .app-content {
  299. width: #{702rpx};
  300. background-color: #ffe7e7;
  301. .app-item {
  302. width: #{70rpx};
  303. height: #{82rpx};
  304. margin-right: #{16rpx};
  305. margin-bottom: #{20rpx};
  306. z-index: 1000;
  307. position: relative;
  308. .app-avatar {
  309. width: #{70rpx};
  310. height: #{70rpx};
  311. border-radius: 50%;
  312. background-color: white;
  313. }
  314. .app-name {
  315. position: absolute;
  316. bottom: 0;
  317. left: 50%;
  318. transform: translateX(-50%);
  319. background-color: #ff5c5c;
  320. color: white;
  321. line-height: #{26rpx};
  322. width: #{56rpx};
  323. height: #{26rpx};
  324. font-size: #{16rpx};
  325. border-radius: #{10rpx};
  326. text-align: center;
  327. }
  328. }
  329. .app-add {
  330. .app-add-avatar {
  331. border: #{1rpx} solid #ff6363;
  332. }
  333. }
  334. .app-no {
  335. }
  336. }
  337. }
  338. .app-share {
  339. width: #{702rpx};
  340. height: #{88rpx};
  341. line-height: #{88rpx};
  342. border-radius: #{46rpx};
  343. text-align: center;
  344. font-size: #{32rpx};
  345. color: #ffffff;
  346. margin: #{24rpx} 0 #{32rpx} 0;
  347. }
  348. .buy-btn {
  349. position: absolute;
  350. bottom: 0;
  351. left: 0;
  352. color: #ffffff;
  353. z-index: 1550;
  354. width: 100%;
  355. height: #{110rpx};
  356. }
  357. }
  358. </style>