editUser.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view>
  3. <view class="content pb180">
  4. <view class="info-item">
  5. <view class="label">姓名</view>
  6. <view class="right">
  7. <text class="text">{{name}}</text>
  8. </view>
  9. </view>
  10. <view class="info-item">
  11. <view class="label">性别</view>
  12. <view class="right">
  13. <view class="fs28" :class="sex?'base-color-0':'base-color-6'"
  14. @click="show=!show">{{sex?sex:'请输入性别'}}</view>
  15. <u-picker :show="show" :columns="columns" @confirm='confirm'
  16. @cancel='show=!show'></u-picker>
  17. </view>
  18. </view>
  19. <view class="info-item">
  20. <view class="label">年龄</view>
  21. <view class="right">
  22. <input type="text" v-model="age" placeholder="请输入年龄" class="input"></text>
  23. </view>
  24. </view>
  25. <view class="info-item">
  26. <view class="label">行为习惯</view>
  27. <view class="right">
  28. <input type="text" v-model="habits" placeholder="请输入行为习惯" class="input"></text>
  29. </view>
  30. </view>
  31. <view class="info-item">
  32. <view class="label">患病时间</view>
  33. <view class="right">
  34. <input type="text" v-model="illnessTime" placeholder="请输入患病时间" class="input"></text>
  35. </view>
  36. </view>
  37. <view class="info-item">
  38. <view class="label">疾病</view>
  39. <view class="right">
  40. <input type="text" v-model="disease" placeholder="请输入疾病" class="input"></text>
  41. </view>
  42. </view>
  43. <view class="info-item">
  44. <view class="label">家人的疾病</view>
  45. <view class="right">
  46. <input type="text" v-model="familyDisease" placeholder="请输入家人的疾病" class="input"></text>
  47. </view>
  48. </view>
  49. <view class="info-item">
  50. <view class="label">是否线下就诊</view>
  51. <view class="right">
  52. <input type="text" v-model="isLine" placeholder="请输入是否线下就诊" class="input"></text>
  53. </view>
  54. </view>
  55. <view class="info-item">
  56. <view class="label">体质</view>
  57. <view class="right">
  58. <input type="text" v-model="constitution" placeholder="请输入体质" class="input"></text>
  59. </view>
  60. </view>
  61. <view class="info-item">
  62. <view class="label">使用药品</view>
  63. <view class="right">
  64. <input type="text" v-model="medicine" placeholder="请输入使用药品" class="input"></text>
  65. </view>
  66. </view>
  67. <view class="info-item">
  68. <view class="label">咨询产品</view>
  69. <view class="right">
  70. <input type="text" v-model="consultProduct" placeholder="请输入咨询产品" class="input"></text>
  71. </view>
  72. </view>
  73. <view class="info-item">
  74. <view class="label">是否已经购买产品</view>
  75. <view class="right">
  76. <input type="text" v-model="isBuy" placeholder="请输入是否已经购买产品" class="input"></text>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="btn-box">
  81. <view class="sub-btn" @click="submit()">保存修改</view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import { getcustomer,updataUser } from "@/api/user.js";
  87. export default {
  88. data() {
  89. return {
  90. name:"",
  91. deptName:"",
  92. postNames:"",
  93. sexPicker: ['男', '女','未知'],
  94. sex: 0, // 性别
  95. age:"",
  96. habits:"",//行为习惯
  97. illnessTime:"",//患病时间
  98. disease:"",//疾病
  99. familyDisease:"",//家人疾病
  100. isLine:"",//是否线下就诊
  101. constitution:"",//体质
  102. medicine:"",//使用药品
  103. consultProduct:"",//咨询产品
  104. isBuy:"",//是否已经购买产品
  105. externalUserId:'',
  106. show: false,
  107. columns: [
  108. ['男', '女', '未知']
  109. ],
  110. }
  111. },
  112. onLoad(options) {
  113. console.log('获取企微id',options)
  114. this.externalUserId=options.externalUserId
  115. this.getuser()
  116. },
  117. methods: {
  118. confirm(e) {
  119. console.log('confirm', e)
  120. this.sex=e.value[0]
  121. this.show = false
  122. },
  123. bindUser(data){
  124. var that=this;
  125. this.name=data.name,
  126. that.sex=data.sex;
  127. that.age=data.age;
  128. that.habits=data.habits;
  129. that.illnessTime=data.illnessTime;
  130. that.disease=data.disease;
  131. that.familyDisease=data.familyDisease;
  132. that.isLine=data.isLine;
  133. that.constitution=data.constitution;
  134. that.medicine=data.medicine;
  135. that.consultProduct=data.consultProduct;
  136. that.isBuy=data.isBuy;
  137. },
  138. getuser(){
  139. const data={
  140. qwExternalContactId:this.externalUserId
  141. }
  142. getcustomer(data).then(res=>{
  143. if (res.code == 200) {
  144. this.detailUser=res.data
  145. // this.moreInfo=res.moreInfo
  146. // this.name=res.data.name;
  147. this.bindUser(res.moreInfo);
  148. } else {
  149. uni.showToast({
  150. icon: 'none',
  151. title: res.msg
  152. })
  153. }
  154. })
  155. },
  156. // 性别选择
  157. pickerSex(e) {
  158. console.log(e)
  159. this.sex = e.detail.value
  160. },
  161. submit(){
  162. // if (this.utils.isEmpty(this.sex)) {
  163. // uni.showToast({
  164. // title: "请输入性别",
  165. // icon: 'none',
  166. // });
  167. // return
  168. // }
  169. // if (this.utils.isEmpty(this.age)) {
  170. // uni.showToast({
  171. // title: "请输入年龄",
  172. // icon: 'none',
  173. // });
  174. // return
  175. // }
  176. uni.showLoading({
  177. title: '加载中'
  178. });
  179. var data = {
  180. externalContactId:this.externalUserId,
  181. name:this.phonenumber,
  182. age:this.age,
  183. sex:this.sex.toString(),
  184. habits:this.habits,
  185. illnessTime:this.illnessTime,
  186. disease:this.disease,
  187. familyDisease:this.familyDisease,
  188. isLine:this.isLine,
  189. constitution:this.constitution,
  190. medicine:this.medicine,
  191. consultProduct:this.consultProduct,
  192. isBuy:this.isBuy
  193. };
  194. console.log(data);
  195. updataUser(data).then(
  196. res => {
  197. uni.hideLoading();
  198. if(res.code==200){
  199. uni.showToast({
  200. title: '修改成功',
  201. duration: 2000
  202. });
  203. // setTimeout(function() {
  204. // uni.navigateBack({
  205. // success: () => {
  206. // }
  207. // })
  208. // }, 500);
  209. this.getuser()
  210. }
  211. else{
  212. uni.showToast({
  213. title: res.msg,
  214. icon: 'none',
  215. });
  216. }
  217. },
  218. rej => {}
  219. );
  220. }
  221. }
  222. }
  223. </script>
  224. <style scoped lang="scss">
  225. .base-color-0{
  226. color: #000;
  227. }
  228. .content{
  229. padding-top: 20rpx;
  230. border-top: 1px solid #F5F6FA;
  231. }
  232. .info-item{
  233. height: 104upx;
  234. background: #FFFFFF;
  235. padding: 0 30upx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. border-bottom: 1px solid #F5F6FA;
  240. &:last-child{
  241. border-bottom: none;
  242. }
  243. .label{
  244. font-size: 30upx;
  245. font-family: PingFang SC;
  246. font-weight: 400;
  247. color: #0F1826;
  248. }
  249. .right{
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. .text{
  254. font-size: 30upx;
  255. font-family: PingFang SC;
  256. font-weight: 400;
  257. color: #0F1826;
  258. }
  259. .image{
  260. margin-left: 10upx;
  261. width: 30upx;
  262. height: 30upx;
  263. }
  264. .input{
  265. text-align: right;
  266. font-size: 30upx;
  267. font-family: PingFang SC;
  268. font-weight: 400;
  269. color: #0F1826;
  270. }
  271. }
  272. .head{
  273. border-radius: 50%;
  274. width: 80upx;
  275. height: 80upx;
  276. }
  277. .arrow{
  278. width: 30upx;
  279. height: 30upx;
  280. }
  281. .text{
  282. font-size: 30upx;
  283. font-family: PingFang SC;
  284. font-weight: 400;
  285. color: #0F1826;
  286. }
  287. .input{
  288. text-align: right;
  289. font-size: 30upx;
  290. font-family: PingFang SC;
  291. font-weight: 400;
  292. color: #0F1826;
  293. }
  294. &.password{
  295. margin-top: 20upx;
  296. .right{
  297. display: flex;
  298. align-items: center;
  299. .text{
  300. font-size: 30upx;
  301. font-family: PingFang SC;
  302. font-weight: 400;
  303. color: #0F1826;
  304. margin-right: 15upx;
  305. }
  306. }
  307. }
  308. }
  309. .btn-box{
  310. margin-top: 15rpx;
  311. padding: 0 30upx;
  312. position: fixed;
  313. bottom: 0;
  314. background-color: #FFFFFF;
  315. padding-top: 30rpx;
  316. padding-bottom: 30rpx;
  317. width: 100%;
  318. align-items: center;
  319. justify-content: center;
  320. .sub-btn{
  321. width: 100%;
  322. height: 88upx;
  323. line-height: 88upx;
  324. text-align: center;
  325. font-size: 30upx;
  326. font-family: PingFang SC;
  327. font-weight: bold;
  328. color: #FFFFFF;
  329. background: #078df3;
  330. border-radius: 44upx;
  331. }
  332. }
  333. </style>