createdRoom.vue 7.3 KB

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