index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <page title="创建房间" ref="pageRef" nav-color="#fff">
  3. <!-- <view
  4. class="pagae-nav"
  5. :style="{ paddingTop: statusBarHeight + 'px', background: headerBg }"
  6. >
  7. <view class="flex-align-center relative" style="height: 80rpx">
  8. <text class="cuIcon-back back" @click.stop="back"></text>
  9. <view class="title line-ellipsis">创建房间</view>
  10. </view>
  11. </view> -->
  12. <view>
  13. <view class="flex-align toolInfo">
  14. <view class="cuIcon-infofill"></view>
  15. <view class="marginL8">房间名称及房间介绍不得带有宣传与本平台无关的内容</view>
  16. </view>
  17. <view class="content-wrapper">
  18. <view class="flex-align paddingY12 line">
  19. <view class="title">房间名:</view>
  20. <view class="flex1">
  21. <input
  22. v-model="name"
  23. placeholder="输入房间名称,最多15个汉字"
  24. class="input"
  25. maxlength="15"
  26. />
  27. </view>
  28. </view>
  29. <view class="flex-align paddingY12 line">
  30. <view class="title">活动介绍:</view>
  31. <view class="flex1">
  32. <input
  33. v-model="description"
  34. placeholder="输入活动介绍,最多15个汉字"
  35. class="input"
  36. maxlength="15"
  37. />
  38. </view>
  39. </view>
  40. <view class="flex-align paddingY12 line">
  41. <view class="title">进房口令:</view>
  42. <view class="flex1">
  43. <input
  44. v-model="password"
  45. placeholder="(可选)用户输入口令才能进房间"
  46. class="input"
  47. maxlength="15"
  48. />
  49. </view>
  50. </view>
  51. <view v-if="!!password" class="flex-align paddingY12 line">
  52. <view class="title">参加模式:</view>
  53. <view class="flex1 flex-align-around">
  54. <view class="flex-align" @click="mode = 0">
  55. <image
  56. :src="mode == 0 ? resource.icon_check : resource.icon_un_check"
  57. style="width: 32rpx; height: 32rpx"
  58. />
  59. <view class="font4 marginL5">进房即参加</view>
  60. </view>
  61. <view class="flex-align" @click="mode = 1">
  62. <image
  63. :src="mode == 1 ? resource.icon_check : resource.icon_un_check"
  64. style="width: 32rpx; height: 32rpx"
  65. />
  66. <view class="font4 marginL5">审核后参加</view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="flex-align paddingY12 line" @click="showTime">
  71. <view class="title">开奖时间:</view>
  72. <view class="flex1" :style="{ color: luckTime ? '#000' : '#777778' }">
  73. {{ luckTime || '设置开奖时间(一个月内)' }}
  74. </view>
  75. </view>
  76. <view class="paddingY12">
  77. <view class="title">赠品:</view>
  78. <view class="flex-wrap paddingT17 flex-align">
  79. <view v-for="(item, index) in goodsList" :key="item.id" class="item">
  80. <view class="marginT11 flex-align-center">
  81. <image :src="item.spu.cover" mode="aspectFill" class="image" />
  82. </view>
  83. <image
  84. :src="LEVEL_MAP[item.level].titleImg"
  85. class="title-level translateX"
  86. />
  87. <view
  88. class="minus cuIcon-roundclosefill"
  89. @click="minus(item, index)"
  90. ></view>
  91. </view>
  92. <view class="add flex-column-align-center" @click="showStoreChoose">
  93. <view class="cuIcon-roundadd icon"></view>
  94. <view class="font4 paddingT18">选择赠品</view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="bottom-wrapper">
  100. <view class="paddingB15 flex-align-center">
  101. <view class="font3 flex-align" @click="showWeb">
  102. 阅读并同意
  103. <text class="color-theme">《福利房使用协议》</text>
  104. </view>
  105. <switch
  106. class="purple marginL10"
  107. @change="changeChecked"
  108. :checked="checked"
  109. ></switch>
  110. </view>
  111. <view class="flex-align-center">
  112. <view class="btn-create" @click="submit">确认创建</view>
  113. </view>
  114. </view>
  115. </view>
  116. <yu-datetime-picker ref="dateTime" current @confirm="onConfirm"></yu-datetime-picker>
  117. </page>
  118. </template>
  119. <script>
  120. import resource from '@/utils/resource'
  121. import yuDatetimePicker from '@/components/yu-datetime-picker'
  122. import { LEVEL_MAP } from '@/utils/config'
  123. import { H5 } from '@/utils/config'
  124. export default {
  125. components: { yuDatetimePicker },
  126. data() {
  127. return {
  128. resource,
  129. LEVEL_MAP,
  130. goodsList: [],
  131. goodsMap: {},
  132. name: '',
  133. mode: 0,
  134. description: '',
  135. password: '',
  136. luckTime: '',
  137. checked: true
  138. }
  139. },
  140. onLoad(options) {
  141. this.$event.on(this.$event.key.STORE_CHOOSE, (map) => {
  142. this.goodsMap = map
  143. this.goodsList = Object.values(map)
  144. })
  145. },
  146. onUnload() {
  147. this.$event.off(this.$event.key.STORE_CHOOSE)
  148. },
  149. methods: {
  150. onConfirm(e) {
  151. this.luckTime = e.selectRes
  152. },
  153. minus(item, index) {
  154. delete this.goodsMap[item.id]
  155. this.goodsList.splice(index, 1)
  156. this.goodsList = [...this.goodsList]
  157. },
  158. showTime() {
  159. this.$refs.dateTime.show()
  160. },
  161. showStoreChoose() {
  162. this.$cache.set(this.$cache.key.STORE_CHOOSE, this.goodsMap)
  163. this.$router.push('store-choose')
  164. },
  165. changeChecked(e) {
  166. this.checked = e.detail.value
  167. },
  168. showWeb() {
  169. this.$router.web(H5.room.url, H5.room.title)
  170. },
  171. submit() {
  172. if (!this.name || !this.description || !this.luckTime) {
  173. this.$message.error('请完善表单')
  174. return
  175. }
  176. if (!this.goodsList || this.goodsList.length === 0) {
  177. this.$message.error('请完善赠品')
  178. return
  179. }
  180. if (!this.checked) {
  181. this.$message.error('请勾选协议')
  182. return
  183. }
  184. this.$message.confirm('确定要创建房间吗?', () => {
  185. this.realSubmit()
  186. })
  187. },
  188. async realSubmit() {
  189. const param = {
  190. description: this.description,
  191. inventoryIds: this.goodsList.map((item) => item.id),
  192. luckTime: this.luckTime,
  193. name: this.name,
  194. password: this.password
  195. }
  196. if (!!this.password) {
  197. param.participateMode = this.mode
  198. }
  199. const res = await this.$service.weal.create(param)
  200. if (res) {
  201. this.$event.emit(this.$event.key.WEAL_REFRESH)
  202. this.$router.back()
  203. }
  204. }
  205. }
  206. }
  207. </script>
  208. <style></style>
  209. <style lang="scss" scoped>
  210. .wrapper {
  211. padding-bottom: 260rpx;
  212. }
  213. .content-wrapper {
  214. margin: 0 14px;
  215. padding-bottom: 260rpx;
  216. .title {
  217. width: 160rpx;
  218. font-size: 28rpx;
  219. }
  220. .line {
  221. // box-shadow: inset 0px 2rpx 20rpx 60rpx rgba(0,0,0,0.55);
  222. border-bottom: 2rpx solid rgba(255, 255, 255, 0.1);
  223. }
  224. .item,
  225. .add {
  226. width: 192rpx;
  227. height: 256rpx;
  228. border-radius: 8rpx;
  229. margin-right: 20rpx;
  230. position: relative;
  231. background: #f0f0f0;
  232. margin-block: 20rpx;
  233. .icon {
  234. font-size: 28rpx;
  235. }
  236. }
  237. .item {
  238. .image {
  239. width: 156rpx;
  240. height: 194rpx;
  241. border-radius: 8rpx;
  242. }
  243. .num {
  244. position: absolute;
  245. left: 0;
  246. top: 0;
  247. height: 24rpx;
  248. line-height: 24rpx;
  249. border-radius: 8rpx 0px 8rpx 0px;
  250. font-size: 24rpx;
  251. font-weight: bold;
  252. padding: 0 24rpx;
  253. color: #fff;
  254. }
  255. .title-level {
  256. position: absolute;
  257. bottom: 16rpx;
  258. width: 90rpx;
  259. height: 32rpx;
  260. }
  261. .minus {
  262. position: absolute;
  263. right: -5rpx;
  264. top: -10rpx;
  265. font-size: 32rpx;
  266. }
  267. }
  268. }
  269. .bottom-wrapper {
  270. padding-bottom: 48rpx;
  271. position: fixed;
  272. bottom: 0;
  273. left: 0;
  274. right: 0;
  275. background-color: #fff;
  276. padding-top: 20rpx;
  277. }
  278. .btn-create {
  279. width: 426rpx;
  280. height: 64rpx;
  281. background: #fec433;
  282. border-radius: 178rpx 178rpx 178rpx 178rpx;
  283. font-size: 28rpx;
  284. font-family: Source Han Sans, Source Han Sans;
  285. font-weight: 400;
  286. color: #000000;
  287. text-align: center;
  288. line-height: 64rpx;
  289. }
  290. .input {
  291. height: 32rpx;
  292. }
  293. .toolInfo {
  294. color: #000;
  295. padding: 20rpx;
  296. background: #f0cd49;
  297. font-size: 24rpx;
  298. text-align: center;
  299. }
  300. </style>