index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <uni-forms ref="form" v-model="form" :rules="rules" label-width="auto">
  6. <uni-forms-item label="人数限制" name="person_limit">
  7. <uni-easyinput type="number" v-model="form.person_limit" placeholder="请输入人数限制" />
  8. </uni-forms-item>
  9. <uni-forms-item label="开始时间" name="start_time">
  10. <uni-datetime-picker type="datetime" v-model="form.start_time" @change="startChange" />
  11. </uni-forms-item>
  12. <uni-forms-item label="结束时间" name="end_time">
  13. <uni-datetime-picker type="datetime" v-model="form.end_time" @change="endChange" />
  14. </uni-forms-item>
  15. </uni-forms>
  16. <view class="btn">
  17. <button type="primary" size="mini" @click="onSubmit('form')">确认开团</button>
  18. </view>
  19. </view>
  20. <view class="two">
  21. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  22. <view class="list-scroll-view">
  23. <view class="two_1" v-if="list.length>0">{{list[0].goods&&list[0].goods.name}}</view>
  24. <view class="list" v-for="(item,index) in list" :key="index">
  25. <view class="list_1">
  26. <view class="list_1_1">
  27. <view class="goods">
  28. <view class="goods_1">
  29. <image class="image"
  30. v-if="item.spec&&item.spec.file&&item.spec.file.length>0"
  31. :src="item.spec.file&&item.spec.file.length>0?item.spec.file[0].url:''"
  32. mode=""></image>
  33. <image class="image" v-else
  34. :src="item.goods&&item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''"
  35. mode=""></image>
  36. </view>
  37. <view class="goods_2">
  38. <view class="goodsname textOver">
  39. {{item.spec&&item.spec.name||'暂无'}}
  40. </view>
  41. <view class="other_2">
  42. 会员提成金额:<text>¥{{item.leader_get||'暂无'}}</text>
  43. </view>
  44. <view class="other_2">
  45. 团购价:<text>¥{{item.price||'暂无'}}</text>
  46. </view>
  47. <view class="other_2">
  48. 会员价:<text>¥{{item.leader_price||'暂无'}}</text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </scroll-view>
  57. </view>
  58. </view>
  59. </mobile-frame>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. user: {},
  66. id: '',
  67. form: {},
  68. list: [],
  69. rules: {
  70. person_limit: {
  71. rules: [{
  72. required: true,
  73. errorMessage: '请输入人数限制',
  74. }]
  75. },
  76. start_time: {
  77. rules: [{
  78. required: true,
  79. errorMessage: '请选择开始时间'
  80. }]
  81. },
  82. end_time: {
  83. rules: [{
  84. required: true,
  85. errorMessage: '请选择结束时间'
  86. }]
  87. }
  88. },
  89. };
  90. },
  91. onLoad: function(e) {
  92. const that = this;
  93. that.$set(that, `form`, e || {});
  94. },
  95. onShow: function(e) {
  96. const that = this;
  97. that.watchLogin();
  98. },
  99. methods: {
  100. // 监听用户是否登录
  101. watchLogin() {
  102. const that = this;
  103. uni.getStorage({
  104. key: 'token',
  105. success: async function(res) {
  106. let user = that.$jwt(res.data);
  107. if (user) {
  108. that.$set(that, `user`, user);
  109. let res = await that.$api(`/goodsConfig`, `GET`, that.form, 'group');
  110. if (res.errcode == '0') {
  111. that.$set(that.form, `group_config`, res.data);
  112. that.$set(that, `list`, res.data);
  113. }
  114. }
  115. },
  116. fail: function(err) {
  117. uni.navigateTo({
  118. url: '/pages/login/index'
  119. })
  120. }
  121. })
  122. },
  123. // 开始时间选择
  124. startChange(e) {
  125. const that = this;
  126. that.$set(that.form, `start_time`, e);
  127. },
  128. // 结束时间选择
  129. endChange(e) {
  130. const that = this;
  131. that.$set(that.form, `end_time`, e);
  132. },
  133. // 提交保存
  134. onSubmit(ref) {
  135. const that = this;
  136. uni.showModal({
  137. title: '提示',
  138. content: '确定是否开团吗?',
  139. success: async function(res) {
  140. that.$set(that.form, `leader`, that.user.id || '');
  141. that.$set(that.form, `status`, '0');
  142. that.$refs[ref].validate().then(async params => {
  143. // 创建团数据
  144. let res = await that.$api(`/group`, 'POST', that.form, 'group');
  145. if (res.errcode == '0') {
  146. uni.reLaunch({
  147. url: `/pagesHome/group/share?id=${res.data.goods}&group=${res.data._id}`
  148. })
  149. } else {
  150. uni.showToast({
  151. title: res.errmsg,
  152. icon: 'none'
  153. })
  154. }
  155. })
  156. }
  157. });
  158. },
  159. }
  160. }
  161. </script>
  162. <style lang="scss">
  163. .main {
  164. display: flex;
  165. flex-direction: column;
  166. width: 100vw;
  167. height: 100vh;
  168. .one {
  169. padding: 2vw;
  170. .toLoacl {
  171. margin: 1vw 0 0 0;
  172. }
  173. .picker {
  174. border: 1px solid #3333;
  175. border-radius: 5px;
  176. padding: 2vw;
  177. }
  178. .btn {
  179. text-align: center;
  180. button {
  181. width: 30%;
  182. font-size: 14px;
  183. background-color: var(--f35BColor);
  184. }
  185. }
  186. }
  187. .two {
  188. position: relative;
  189. flex-grow: 1;
  190. .two_1 {
  191. background-color: #fff;
  192. padding: 2vw;
  193. margin: 2vw;
  194. border-radius: 5px;
  195. }
  196. .list {
  197. background-color: var(--f9Color);
  198. padding: 2vw;
  199. margin: 0 2vw 2vw 2vw;
  200. border-radius: 5px;
  201. .list_1 {
  202. .list_1_1 {
  203. border-bottom: 1px solid #f1f1f1;
  204. .goods {
  205. display: flex;
  206. padding: 0 0 2vw 0;
  207. .goods_1 {
  208. width: 20vw;
  209. height: 20vw;
  210. .image {
  211. width: 100%;
  212. height: 100%;
  213. border-radius: 5px;
  214. }
  215. }
  216. .goods_2 {
  217. width: 70vw;
  218. padding: 0 0 0 2vw;
  219. .goodsname {
  220. font-size: 16px;
  221. margin: 0 0 1vw 0;
  222. }
  223. .time {
  224. font-size: var(--font14Size);
  225. text {
  226. color: #858585;
  227. }
  228. }
  229. .other_2 {
  230. font-size: var(--font14Size);
  231. text {
  232. color: var(--fFB1Color);
  233. padding: 0 2vw 0 0;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. }
  242. }
  243. </style>