index.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <div id="app" v-cloak>
  2. <el-card class="box-card" shadow="never" style="border:0;min-width: 1250px;"
  3. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  4. <div slot="header">
  5. <el-breadcrumb separator="/">
  6. <el-breadcrumb-item>
  7. <span style="color: #409EFF;cursor: pointer"
  8. @click="$navigate({r:'mall/set-mobile/index'})">设置</span>
  9. </el-breadcrumb-item>
  10. <el-breadcrumb-item>修改登录手机号</el-breadcrumb-item>
  11. </el-breadcrumb>
  12. </div>
  13. <div class="form-body" style="padding: 20px 45% 0 10px">
  14. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="160px">
  15. <el-row>
  16. <el-col :span="24">
  17. <el-form-item :label="ruleForm.login.old_mobile.title">
  18. <el-col :span="6">
  19. <el-input v-model="ruleForm.login.old_mobile.value" disabled='disabled'></el-input>
  20. <div class="tips-text" v-if="ruleForm.login.old_mobile.remark">
  21. {{ruleForm.login.old_mobile.remark}}
  22. </div>
  23. </el-col>
  24. </el-form-item>
  25. <el-form-item :label="ruleForm.login.old_mobile.code_title">
  26. <el-col :span="6" style="display:flex">
  27. <el-input v-model="ruleForm.login.old_mobile.verify_code"
  28. style="margin-right:10px;"></el-input>
  29. <el-button @click="getVerificationCode('old')" :disabled="is_disabled_old">获取验证码
  30. </el-button>
  31. </el-col>
  32. </el-form-item>
  33. <el-form-item :label="ruleForm.login.new_mobile.title">
  34. <el-col :span="6">
  35. <el-input v-model="ruleForm.login.new_mobile.value"></el-input>
  36. <div class="tips-text" v-if="ruleForm.login.new_mobile.remark">
  37. {{ruleForm.login.new_mobile.remark}}
  38. </div>
  39. </el-col>
  40. </el-form-item>
  41. <el-form-item :label="ruleForm.login.new_mobile.code_title">
  42. <el-col :span="6" style="display:flex">
  43. <el-input v-model="ruleForm.login.new_mobile.verify_code"
  44. style="margin-right:10px;"></el-input>
  45. <el-button @click="getVerificationCode('new')" :disabled="is_disabled_new">获取验证码
  46. </el-button>
  47. </el-col>
  48. </el-form-item>
  49. <el-form-item label="开启短信登录">
  50. <el-col :span="14">
  51. <el-switch :disabled="!is_super" v-model="ruleForm.login.open_sms_login.value" :active-value="1"
  52. :inactive-value="0"></el-switch>
  53. </el-col>
  54. </el-form-item>
  55. <el-form-item>
  56. <div class="tips-text">开启短信验证码登录,需要开启短信服务,请在"设置->商城设置->短信提醒"中开启短信服务,及在"设置->员工管理->员工列表"确认账户已经填写了手机号码。</div>
  57. </el-form-item>
  58. <el-form-item>
  59. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;" @click="submit" size="small">保存
  60. </el-button>
  61. </el-form-item>
  62. </el-col>
  63. </el-row>
  64. </el-form>
  65. </div>
  66. </el-card>
  67. </div>
  68. <script>
  69. const app = new Vue({
  70. el: '#app',
  71. data() {
  72. return {
  73. mall_id: <?= $mall_id ?>,
  74. is_super: <?=$is_super ?>,
  75. is_disabled_old:false,
  76. is_disabled_new:false,
  77. btnLoading:false,
  78. ruleForm: {
  79. login: {
  80. old_mobile:{title:"旧手机号",value:'',remark:"",code_title:"手机验证码",verify_code:""},
  81. new_mobile:{title:"新手机号",value:'',remark:"",code_title:"手机验证码",verify_code:""},
  82. open_sms_login:{value:0},
  83. }
  84. }
  85. }
  86. },
  87. mounted() {
  88. this.loadData()
  89. },
  90. methods: {
  91. getVerificationCode(type) {
  92. let mobile = ''
  93. if(type == 'old'){
  94. mobile = this.ruleForm.login.old_mobile.value
  95. this.setDisabled(type,true)
  96. }
  97. if(type == 'new'){
  98. mobile = this.ruleForm.login.new_mobile.value
  99. this.setDisabled(type,true)
  100. }
  101. if(!mobile){
  102. this.$message.error('请填写手机号再获取验证码');
  103. return
  104. }
  105. request({
  106. params: {
  107. r: 'common/sms/send',
  108. },
  109. method: 'post',
  110. data: {
  111. mobile : mobile,
  112. sms_type : 'EditAdminMobile',
  113. valid_time : 60,
  114. mall_id : this.mall_id
  115. }
  116. }).then(e => {
  117. this.setDisabled(type,false)
  118. if (e.data.code == 0) {
  119. this.$message.success(e.data.msg+',验证码已发送到:'+mobile);
  120. } else {
  121. this.$message.error(e.data.msg);
  122. }
  123. }).catch(e => {
  124. });
  125. },
  126. loadData() {
  127. if(this.loading === true) return;
  128. this.loading = true;
  129. request({
  130. params: {
  131. r: 'mall/set-mobile/index'
  132. },
  133. method: 'get'
  134. }).then(e => {
  135. this.loading = false;
  136. if (e.data.code == 0) {
  137. if(e.data.data) {//有选中的
  138. let data = e.data.data
  139. this.mall_sign = data.mall_sign;
  140. Object.keys(this.ruleForm).forEach((key) => {
  141. Object.keys(this.ruleForm[key]).forEach((k) => {
  142. if (!isEmpty(data[key][k])) {
  143. var dataValue = data[key][k].value;
  144. if(data[key][k].value!==null&&data[key][k].value!==""){
  145. if (typeof dataValue == 'string' && (dataValue.indexOf("{") !== -1 || dataValue.indexOf("[") !== -1)) {
  146. // 将json字符串转为对象
  147. this.ruleForm[key][k].value = JSON.parse(data[key][k].value);
  148. }else{
  149. this.ruleForm[key][k].value = data[key][k].value;
  150. }
  151. }
  152. }
  153. });
  154. });
  155. }
  156. }
  157. }).catch(e => {
  158. this.loading = false;
  159. })
  160. },
  161. submit() {
  162. let InitDataPara = {}
  163. // 对象深拷贝
  164. InitDataPara = JSON.parse(JSON.stringify(this.ruleForm));
  165. this.btnLoading = true;
  166. this.$request({
  167. params: {
  168. r: 'mall/set-mobile/index',
  169. },
  170. method: 'post',
  171. data: {
  172. setting: InitDataPara,
  173. },
  174. }).then(e => {
  175. this.btnLoading = false;
  176. if (e.data.code === 0) {
  177. this.$message.success(e.data.msg);
  178. } else {
  179. this.$message.error(e.data.msg);
  180. }
  181. }).catch(e => {
  182. this.btnLoading = false;
  183. });
  184. },
  185. setDisabled(type,disabled){
  186. if(type == 'old'){
  187. this.is_disabled_old = disabled
  188. }
  189. if(type == 'new'){
  190. this.is_disabled_new = disabled
  191. }
  192. },
  193. }
  194. })
  195. </script>