user_add.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <view class="page">
  3. <ul class="profile" >
  4. <li>登录账号:</li>
  5. <li style='position: relative;'>
  6. <input type="text" style="width: 150px;" maxlength="10" class="input1" placeholder="请输入登录账号" v-model="form.username" @blur="check_name($event.detail.value)" />
  7. <uni-icons :type="usernamemsg=='ok'?'checkbox-filled':'clear'" :class="{'tip-icons':true,'ok':usernamemsg=='ok','error':usernamemsg=='error'}" ></uni-icons>
  8. </li>
  9. </ul>
  10. <ul class="profile" >
  11. <li>登录密码:</li>
  12. <li>
  13. <input type="password" style="width: 150px;" maxlength="10" class="input1" placeholder="默认密码:123456" v-model="form.password"/>
  14. </li>
  15. </ul>
  16. <ul class="profile" >
  17. <li>用户类型:</li>
  18. <li>
  19. <radio :checked="form.isdaili==true" @tap="set_daili(true)" >代理</radio>
  20. <radio style="margin-left: 10px;" :checked="form.isdaili!=true" @tap="set_daili(false)" >用户</radio>
  21. </li>
  22. </ul>
  23. <ul class="profile" style='display: none;' >
  24. <li>返点比例:</li>
  25. <li>
  26. <picker @change="change_rebate" :value="rebate_index" :range="rebates" :disabled="rebate_disabled" style="display: inline-block;">
  27. <view class="uni-input">{{form.rebate}}%</view>
  28. </picker>
  29. <span style="margin-left:10px;color:#666;">
  30. (
  31. <block v-if="form.isdaili">
  32. 打赏分润占比
  33. </block>
  34. <block v-else>
  35. 用户账号无分润
  36. </block>
  37. </span>
  38. )
  39. </li>
  40. </ul>
  41. <view style="margin:15px auto;display:block;width: 80%;">
  42. <button class="button1" @tap="click_sub()">确认并提交</button>
  43. </view>
  44. <view class="modalhtml" v-if="showModal">
  45. <view class="modal">
  46. <view class="title">
  47. 开户成功
  48. </view>
  49. <view class="content">
  50. 登录账号:{{form.username}}<br>
  51. 登录密码:{{form.password}}<br>
  52. 账号类型:<block v-if="form.isdaili">代理</block><block v-else>用户</block><br>
  53. 访问网址:{{loginurl}}
  54. </view>
  55. <view class="btns" >
  56. <span @tap="showModal=false;">关 闭</span>
  57. <span style="color:#2319DC;font-weight: 600;" @tap="copyinfo()">复 制</span>
  58. </view>
  59. </view>
  60. </view>
  61. <tabbar></tabbar>
  62. </view>
  63. </template>
  64. <script>
  65. import http from "../../library/http.js"
  66. import config from "../../config.js"
  67. import uniIcons from '../../components/uni-icons/uni-icons.vue'
  68. import tabbar from '../../components/tabbar.vue'
  69. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight ;
  70. export default {
  71. components:{
  72. uniIcons,
  73. tabbar
  74. },
  75. data() {
  76. return {
  77. list:[],
  78. user:uni.getStorageSync('userInfo'),
  79. rebates:[],
  80. rebate_disabled:false,
  81. rebate_index:0,
  82. form:{
  83. username:'',
  84. rebate:'',
  85. isdaili:true,
  86. userid:uni.getStorageSync('access_token'),
  87. password:'',
  88. },
  89. showcode:false,
  90. qrcode:'',
  91. qrcode_id:'',
  92. usernamemsg:false,
  93. name_status:false,
  94. showModal:false,
  95. loginurl:config.imgUri
  96. }
  97. },
  98. methods: {
  99. check_name(value) {
  100. var reg=/^[\d\w]+$/;
  101. if(reg.test(value)){
  102. if(value.length>5){
  103. http.setWait(false).post('user.php?act=checkname1',{username:value}).then(res=>{
  104. var data=res.data;
  105. if(res.status==200){
  106. this.name_status=true;
  107. this.usernamemsg='ok';
  108. }else{
  109. this.usernamemsg='error';
  110. this.name_status=false;
  111. uni.showToast({
  112. icon:'none',
  113. title:res.message,
  114. duration:1000
  115. })
  116. }
  117. })
  118. }else{
  119. this.name_status=false;
  120. this.usernamemsg='error';
  121. }
  122. }else{
  123. this.usernamemsg='error';
  124. this.name_status=false;
  125. }
  126. },
  127. set_daili(type){
  128. this.form.isdaili=type;
  129. if(type==true){
  130. this.form.rebate= this.rebates[this.rebate_index];
  131. this.rebate_disabled=false;
  132. }
  133. else{
  134. this.form.rebate=0;
  135. this.rebate_disabled=true;
  136. }
  137. },
  138. change_rebate(e){
  139. var index=e.detail.value;
  140. this.rebate_index=index;
  141. this.form.rebate= this.rebates[this.rebate_index];
  142. },
  143. click_sub(){
  144. this.form.userid=this.user.id;
  145. this.form.isdaili=this.form.isdaili?1:0;
  146. if(this.form.username==''){
  147. uni.showToast({
  148. icon:'none',
  149. title:'请输入用户名',
  150. duration:1000
  151. })
  152. return false;
  153. }
  154. if(this.form.username.length<6){
  155. uni.showToast({
  156. icon:'none',
  157. title:'用户长度不能小于6位',
  158. duration:1000
  159. })
  160. return false;
  161. }
  162. if(this.name_status==false){
  163. uni.showToast({
  164. icon:'none',
  165. title:'该账号已被注册',
  166. duration:1000
  167. })
  168. return false;
  169. }
  170. if(this.form.password=='') this.form.password='123456';
  171. if(this.form.password.length<6){
  172. uni.showToast({
  173. icon:'none',
  174. title:'密码长度不能小于6位',
  175. duration:1000
  176. })
  177. return false;
  178. }
  179. http.setWait(true).post('user.php?act=user_add',this.form).then(res=>{
  180. if(res.code==200){
  181. this.showModal=true;
  182. }
  183. })
  184. },
  185. copyinfo(){
  186. var str="登录账号:"+this.form.username+"\n";
  187. str+="登录密码:"+this.form.password+"\n";
  188. str+="账号类型:";
  189. if(this.form.isdaili) str+="代理";
  190. else str+="用户";
  191. str+="\n";
  192. str+="返点比例:"+this.form.rebate+"\n";
  193. str+="访问网址:"+this.loginurl+"\n";
  194. this.copy(str);
  195. this.showModal=false;
  196. },
  197. timestampToTime(timestamp) {
  198. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  199. var Y = date.getFullYear() ;
  200. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
  201. var D = date.getDate();
  202. var h = date.getHours();
  203. var m = date.getMinutes();
  204. var s = date.getSeconds();
  205. if(D<10) D='0'+D;
  206. if(h<10) h='0'+h;
  207. if(m<10) m='0'+m;
  208. if(s<10) s='0'+s;
  209. return Y+'-'+M+'-'+D;
  210. },
  211. copy(data){
  212. uni.setClipboardData({
  213. data:data,
  214. success() {
  215. uni.showToast({
  216. title:'复制成功',
  217. icon:'none'
  218. })
  219. },
  220. fail: () => {
  221. uni.showToast({
  222. title:'复制失败',
  223. icon:'none'
  224. })
  225. }
  226. })
  227. },
  228. },
  229. onLoad(opts) {
  230. this.user = uni.getStorageSync('userInfo');
  231. this.form.rebate=this.user.rebate-0.5;
  232. this.rebates=[];
  233. for(var i=this.form.rebate;i>=0;i=i-0.5){
  234. this.rebates.push(i.toFixed(1));
  235. }
  236. },
  237. onNavigationBarButtonTap() {
  238. }
  239. }
  240. </script>
  241. <style lang="scss" scoped>
  242. @import "@/static/css/user.css";
  243. .page{
  244. background-color: #fafafa;
  245. }
  246. .modalhtml{
  247. position: fixed;
  248. z-index: 999;
  249. top:0px;
  250. width: 100%;
  251. left: 0px;height: 100vh;
  252. background-color: rgba(0,0,0,0.7);
  253. }
  254. .modalhtml .modal{
  255. background-color: #fff;
  256. border-radius: 10px;;
  257. top:30vh;
  258. width: 80vw;
  259. left: 10vw;
  260. position: fixed;
  261. border: 1px #ddd solid;
  262. }
  263. .modalhtml .modal .title{
  264. text-align: center;
  265. height: 35px;
  266. line-height: 35px;
  267. color: #000;;
  268. font-size: 16px;;
  269. font-weight: 600;
  270. margin-top: 5px;;
  271. }
  272. .modalhtml .modal .content{
  273. padding: 5px 10px;
  274. max-height: 160px;;
  275. min-height: 65px;
  276. line-height: 30px;;
  277. overflow-y: scroll;
  278. font-size: 14px;
  279. }
  280. .modalhtml .modal .btns{
  281. text-align: center;
  282. height: 35px;
  283. line-height: 35px;
  284. color: #000;;
  285. font-size: 16px;;
  286. font-weight: 600;
  287. border-top: #eee 1px solid;
  288. }
  289. .modalhtml .modal .btns >span{
  290. display: inline-block;
  291. width: calc(50% - 1px);
  292. height: 35px;
  293. line-height: 35px;
  294. }
  295. .modalhtml .modal .btns >span:last-child{
  296. border-left: #eee 1px solid;
  297. }
  298. .tip-icons {
  299. position: absolute;
  300. left:180px;
  301. top:-8px;
  302. font-size: 22px !important;
  303. display: none;
  304. }
  305. .tip-icons.ok{
  306. color: #1D830D !important;
  307. display: inline-block;
  308. }
  309. .tip-icons.error{
  310. color: #e7202a !important;
  311. display: inline-block;
  312. }
  313. .tip-icons.active {
  314. color: #2319dc !important;
  315. }
  316. .profile,.login-lines1{
  317. background-color: #fff;
  318. margin: 10px auto;
  319. width: 100%;
  320. vertical-align: middle;
  321. }
  322. .profile li{
  323. vertical-align: middle;
  324. }
  325. .profile li:first-child{
  326. width:120px
  327. }
  328. .profile li:last-child{
  329. width:calc(100% - 130px)
  330. }
  331. .nodata{
  332. height: 40px;
  333. line-height: 40px;
  334. text-align: center;
  335. }
  336. .lists{
  337. background-color: #fff;
  338. margin-top: 10px;
  339. padding: 5px 10px;
  340. line-height: 25px;
  341. clear: both;
  342. display: inline-block;
  343. width: calc(100% - 20px);
  344. }
  345. .lists > view{
  346. clear: both;
  347. }
  348. .lists > view > span{
  349. display: inline-block;
  350. }
  351. .lists > view > span:first-child{
  352. text-align: left;
  353. float: left;
  354. }
  355. .lists > view > span:last-child{
  356. text-align: right;
  357. float: right;
  358. }
  359. .lists > view .title1{
  360. color: #666;
  361. }
  362. .btn1{
  363. display: inline-block;
  364. height: 22px;
  365. line-height: 22px;vertical-align: middle;font-size: 14px;
  366. margin-left: 4px;
  367. background-color: #f8f8f8;
  368. border: 1px #e7e7e7 solid;
  369. border-radius: 5px;
  370. }
  371. .btn2{
  372. display: inline-block;
  373. height: 28px;
  374. line-height: 28px;vertical-align: middle;font-size: 14px;
  375. margin-left: 4px;
  376. background-color: #2319dc;
  377. border: 1px #2319dc solid;
  378. color:#fff;
  379. border-radius: 5px;
  380. padding: 0px 10px;
  381. margin: 0px 15px;
  382. }
  383. .btn2.delete{
  384. background-color: #f8f8f8;
  385. border: 1px #e7e7e7 solid;
  386. color:#222;
  387. padding: 0px 10px;
  388. }
  389. .lists > view.btns{
  390. height: 30px;line-height: 30px;text-align: center;
  391. }
  392. .qrcode{
  393. background-color: rgba($color: #000000, $alpha: 0.5);
  394. position: fixed;
  395. left: 0px;
  396. width: 100%;
  397. height: 100vh;
  398. top:0px;
  399. }
  400. .qrcode .code{
  401. height: 200px;
  402. width: 200px;
  403. top:calc(50% - 150px);
  404. left: calc(50% - 100px);
  405. position: fixed;
  406. }
  407. .qrcode .close{
  408. bottom: 80px;;
  409. left: calc(50% - 20px);
  410. position: fixed;
  411. height: 40px;width: 40px;
  412. }
  413. </style>