app-group-avatar-short.vue 11 KB

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