createdRoom.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div id="createdRoom" @click.stop>
  3. <div class="created_dialog">
  4. <div class="blurBox"></div>
  5. <div class="content">
  6. <div class="dialog_title" v-if="role == 'leader'">{{ $t('common.createTour')}}</div>
  7. <div class="dialog_title" v-else>{{ $t('common.joinTour')}}</div>
  8. <div class="user_name">
  9. <input
  10. class="input_name"
  11. maxlength="20"
  12. v-model.trim="userName"
  13. type="text"
  14. :placeholder="role == 'leader' ? $t('common.leadernickName') : $t('common.inputnickName')"
  15. />
  16. <span class="limitNum">{{ userName.length }}/20</span>
  17. </div>
  18. <!-- <div v-if="role!='customer'" class="mode_btn">
  19. <div @click="chooseMode(i.mode)" v-for="i,index in modeList" :key="index" :class="{ active: mode==i.mode }" class="mode">{{i.title}}</div>
  20. </div> -->
  21. <div class="created_btn">
  22. <div class="created_cancel" @click="closeCreated">{{ $t('common.cancel')}}</div>
  23. <div class="created_confirm" @click="createdConfirm">{{ $t('common.confirm')}}</div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { Dialog } from "@/global_components/";
  31. import browser from "@/utils/browser";
  32. import { useStore } from "vuex";
  33. import { useI18n, getLocale } from '@/i18n'
  34. const { t } = useI18n({ useScope: 'global' })
  35. export default {
  36. data() {
  37. return {
  38. role: browser.getURLParam("role") || "leader",
  39. mode: browser.getURLParam("mode") || 2,
  40. modeList: [
  41. {
  42. mode: 1,
  43. title: "1V1",
  44. },
  45. {
  46. mode: 2,
  47. title: "多人模式",
  48. },
  49. ],
  50. store:useStore(),
  51. userName: "",
  52. roomId: browser.getURLParam("roomId"),
  53. };
  54. },
  55. mounted() {},
  56. components: {},
  57. // created: {},
  58. // mounted:{},
  59. methods: {
  60. getUrl(href, queryArr) {
  61. queryArr.forEach((item) => {
  62. if (!browser.hasURLParam(item.key)) {
  63. let ttt = href.split("index.html?");
  64. href = `${ttt[0]}index.html?${item.key}=${item.val}&${ttt[1]}`;
  65. } else {
  66. href = browser.replaceQueryString(href, item.key, item.val);
  67. }
  68. });
  69. return href;
  70. },
  71. chooseMode(mode) {
  72. this.mode = mode;
  73. },
  74. closeCreated() {
  75. this.$emit("closeCreated");
  76. },
  77. createdConfirm() {
  78. if (this.userName == "") {
  79. Dialog.toast({ content: t('common.inputnickName'), type: "error" });
  80. return;
  81. }
  82. let name = encodeURIComponent(this.userName);
  83. let hh = window.location.href;
  84. if (this.role == "customer") {
  85. let tempUrl = this.getUrl(hh, [
  86. {
  87. key: "mode",
  88. val: this.mode,
  89. },
  90. {
  91. key: "name",
  92. val: name,
  93. },
  94. {
  95. key: "role",
  96. val: "customer",
  97. },
  98. {
  99. key: "roomId",
  100. val: this.roomId,
  101. },
  102. ]);
  103. // history.replaceState(null, null, hh + "&mode=" + this.mode + "&name=" + name + "&role=customer&roomId=" + this.roomId);
  104. history.replaceState(null, null, tempUrl);
  105. } else {
  106. let tempUrl = this.getUrl(hh, [
  107. {
  108. key: "mode",
  109. val: this.mode,
  110. },
  111. {
  112. key: "name",
  113. val: name,
  114. },
  115. {
  116. key: "role",
  117. val: "leader",
  118. },
  119. ]);
  120. // history.replaceState(null, null,hh + "&mode=" + this.mode + "&name=" + name + "&role=leader");
  121. history.replaceState(null, null, tempUrl);
  122. console.log(tempUrl);
  123. }
  124. this.store.commit("rtc/setRole", this.role);
  125. this.$nextTick(() => {
  126. this.$emit("createdConfirm");
  127. });
  128. },
  129. },
  130. };
  131. </script>
  132. <style scoped lang="scss">
  133. #createdRoom {
  134. width: 100vw;
  135. height: 100%;
  136. // background: rgba(0, 0, 0, 0.5);
  137. background: transparent;
  138. position: fixed;
  139. left: 0;
  140. top: 0;
  141. z-index: 1000000;
  142. // pointer-events: none;
  143. .created_dialog {
  144. width: 8.64rem;
  145. min-height: 5rem;
  146. // background: #ffffff;
  147. pointer-events: auto;
  148. position: absolute;
  149. left: 50%;
  150. top: 50%;
  151. transform: translate(-50%, -50%);
  152. // overflow: hidden;
  153. border: 1px solid rgba(255, 255, 255, 0.1);
  154. border-radius: 4px;
  155. .blurBox {
  156. position: absolute;
  157. z-index: 1;
  158. top: 0;
  159. left: 0;
  160. width: 100%;
  161. height: 100%;
  162. background: rgba(0, 0, 0, 0.7);
  163. filter: blur(1px);
  164. }
  165. .content {
  166. position: relative;
  167. z-index: 2;
  168. top: 0;
  169. left: 0;
  170. width: 100%;
  171. height: 100%;
  172. }
  173. .dialog_title {
  174. font-size: 0.39rem;
  175. width: 100%;
  176. height: 1.39rem;
  177. padding: 0 0.56rem;
  178. box-sizing: border-box;
  179. font-size: 0.39rem;
  180. color: #fff;
  181. line-height: 1.39rem;
  182. overflow: hidden;
  183. text-overflow: ellipsis;
  184. white-space: nowrap;
  185. border-bottom-style: solid;
  186. border-bottom-width: 1px;
  187. border-bottom-color: rgba(255, 255, 255, 0.1);
  188. }
  189. .user_name {
  190. width: 100%;
  191. height: 1.11rem;
  192. padding: 0 0.56rem;
  193. box-sizing: border-box;
  194. font-size: 0.39rem;
  195. line-height: 1.11rem;
  196. margin: 0.56rem 0;
  197. position: relative;
  198. .limitNum {
  199. position: absolute;
  200. right: 0.64rem;
  201. top: 50%;
  202. transform: translateY(-50%);
  203. font-size: 0.33rem;
  204. color: #b9bdbc;
  205. }
  206. .input_name {
  207. font-size: 0.39rem;
  208. width: 100%;
  209. height: 100%;
  210. line-height: 1.11rem;
  211. padding: 0 1.066667rem 0 0.28rem;
  212. box-sizing: border-box;
  213. background: rgba(0, 0, 0, 0.5);
  214. border-radius: 4px;
  215. color: #fff;
  216. border: none;
  217. outline: none;
  218. &::placeholder {
  219. color: rgba(255, 255, 255, 0.3);
  220. }
  221. }
  222. }
  223. .mode_btn {
  224. width: 100%;
  225. height: 1.11rem;
  226. padding: 0 0.56rem;
  227. box-sizing: border-box;
  228. display: flex;
  229. align-items: center;
  230. justify-content: space-between;
  231. margin-bottom: 0.56rem;
  232. > div.mode {
  233. width: 3.61rem;
  234. height: 100%;
  235. border-radius: 0.65rem;
  236. border: 0.03rem solid #fff;
  237. color: #fff;
  238. font-size: 0.39rem;
  239. line-height: 1.11rem;
  240. text-align: center;
  241. box-sizing: border-box;
  242. &.active {
  243. color: #ed5d18;
  244. border: 0.03rem solid #ed5d18;
  245. }
  246. }
  247. }
  248. .created_btn {
  249. width: 100%;
  250. height: 1.36rem;
  251. border-top-style: solid;
  252. border-top-width: 1px;
  253. border-top-color: rgba(255, 255, 255, 0.1);
  254. box-sizing: border-box;
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. font-size: 0.39rem;
  259. > div {
  260. width: 50%;
  261. height: 1.36rem;
  262. text-align: center;
  263. line-height: 1.36rem;
  264. font-size: 0.39rem;
  265. box-sizing: border-box;
  266. &.created_cancel {
  267. color: #fff;
  268. border-right-style: solid;
  269. border-right-width: 1px;
  270. border-right-color: rgba(255, 255, 255, 0.1);
  271. }
  272. &.created_confirm {
  273. color: #ed5d18;
  274. }
  275. }
  276. }
  277. }
  278. }
  279. </style>