createdRoom.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 userName = ref('')
  33. const { t } = useI18n({ useScope: "global" });
  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. if (this.userName == "") {
  83. Dialog.toast({ content: this.$t("common.inputnickName"), type: "error" });
  84. return;
  85. }
  86. let name = encodeURIComponent(this.userName);
  87. let hh = window.location.href;
  88. if (this.role == "customer") {
  89. let tempUrl = this.getUrl(hh, [
  90. {
  91. key: "mode",
  92. val: this.mode,
  93. },
  94. {
  95. key: "name",
  96. val: name,
  97. },
  98. {
  99. key: "role",
  100. val: "customer",
  101. },
  102. {
  103. key: "roomId",
  104. val: this.roomId,
  105. },
  106. ]);
  107. // history.replaceState(null, null, hh + "&mode=" + this.mode + "&name=" + name + "&role=customer&roomId=" + this.roomId);
  108. history.replaceState(null, null, tempUrl);
  109. window.parent.postMessage(
  110. {
  111. source: "cdf",
  112. event: "urlReplace",
  113. params: {
  114. tempUrl,
  115. },
  116. },
  117. "*"
  118. );
  119. } else {
  120. let tempUrl = this.getUrl(hh, [
  121. {
  122. key: "mode",
  123. val: this.mode,
  124. },
  125. {
  126. key: "name",
  127. val: name,
  128. },
  129. {
  130. key: "role",
  131. val: "leader",
  132. },
  133. ]);
  134. // history.replaceState(null, null,hh + "&mode=" + this.mode + "&name=" + name + "&role=leader");
  135. history.replaceState(null, null, tempUrl);
  136. console.log(tempUrl);
  137. }
  138. this.store.commit("rtc/setRole", this.role);
  139. this.$nextTick(() => {
  140. this.$emit("createdConfirm");
  141. });
  142. },
  143. },
  144. };
  145. </script>
  146. <style scoped lang="scss">
  147. #createdRoom {
  148. width: 100vw;
  149. height: 100%;
  150. // background: rgba(0, 0, 0, 0.5);
  151. background: transparent;
  152. position: fixed;
  153. left: 0;
  154. top: 0;
  155. z-index: 1000000;
  156. // pointer-events: none;
  157. .created_dialog {
  158. width: 8.64rem;
  159. min-height: 5rem;
  160. // background: #ffffff;
  161. pointer-events: auto;
  162. position: absolute;
  163. left: 50%;
  164. top: 50%;
  165. transform: translate(-50%, -50%);
  166. // overflow: hidden;
  167. border: 1px solid rgba(255, 255, 255, 0.1);
  168. border-radius: 4px;
  169. .blurBox {
  170. position: absolute;
  171. z-index: 1;
  172. top: 0;
  173. left: 0;
  174. width: 100%;
  175. height: 100%;
  176. background: rgba(0, 0, 0, 0.7);
  177. filter: blur(1px);
  178. }
  179. .content {
  180. position: relative;
  181. z-index: 2;
  182. top: 0;
  183. left: 0;
  184. width: 100%;
  185. height: 100%;
  186. }
  187. .dialog_title {
  188. font-size: 0.39rem;
  189. width: 100%;
  190. height: 1.39rem;
  191. padding: 0 0.56rem;
  192. box-sizing: border-box;
  193. font-size: 0.39rem;
  194. color: #fff;
  195. line-height: 1.39rem;
  196. overflow: hidden;
  197. text-overflow: ellipsis;
  198. white-space: nowrap;
  199. border-bottom-style: solid;
  200. border-bottom-width: 1px;
  201. border-bottom-color: rgba(255, 255, 255, 0.1);
  202. }
  203. .user_name {
  204. width: 100%;
  205. height: 1.11rem;
  206. padding: 0 0.56rem;
  207. box-sizing: border-box;
  208. font-size: 0.39rem;
  209. line-height: 1.11rem;
  210. margin: 0.56rem 0;
  211. position: relative;
  212. .limitNum {
  213. position: absolute;
  214. right: 0.64rem;
  215. top: 50%;
  216. transform: translateY(-50%);
  217. font-size: 0.33rem;
  218. color: #b9bdbc;
  219. }
  220. .input_name {
  221. font-size: 0.39rem;
  222. width: 100%;
  223. height: 100%;
  224. line-height: 1.11rem;
  225. padding: 0 1.066667rem 0 0.28rem;
  226. box-sizing: border-box;
  227. background: rgba(0, 0, 0, 0.5);
  228. border-radius: 4px;
  229. color: #fff;
  230. border: none;
  231. outline: none;
  232. &::placeholder {
  233. color: rgba(255, 255, 255, 0.3);
  234. }
  235. }
  236. }
  237. .mode_btn {
  238. width: 100%;
  239. height: 1.11rem;
  240. padding: 0 0.56rem;
  241. box-sizing: border-box;
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. margin-bottom: 0.56rem;
  246. > div.mode {
  247. width: 3.61rem;
  248. height: 100%;
  249. border-radius: 0.65rem;
  250. border: 0.03rem solid #fff;
  251. color: #fff;
  252. font-size: 0.39rem;
  253. line-height: 1.11rem;
  254. text-align: center;
  255. box-sizing: border-box;
  256. &.active {
  257. color: #ed5d18;
  258. border: 0.03rem solid #ed5d18;
  259. }
  260. }
  261. }
  262. .created_btn {
  263. width: 100%;
  264. height: 1.36rem;
  265. border-top-style: solid;
  266. border-top-width: 1px;
  267. border-top-color: rgba(255, 255, 255, 0.1);
  268. box-sizing: border-box;
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. font-size: 0.39rem;
  273. > div {
  274. width: 50%;
  275. height: 1.36rem;
  276. text-align: center;
  277. line-height: 1.36rem;
  278. font-size: 0.39rem;
  279. box-sizing: border-box;
  280. &.created_cancel {
  281. color: #fff;
  282. border-right-style: solid;
  283. border-right-width: 1px;
  284. border-right-color: rgba(255, 255, 255, 0.1);
  285. }
  286. &.created_confirm {
  287. color: #ed5d18;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. </style>