index.vue 5.8 KB

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