editUser.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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:50,
  106. show: false,
  107. columns: [
  108. ['男', '女', '未知']
  109. ],
  110. }
  111. },
  112. onLoad(options) {
  113. // this.externalUserId=options.externalUserId
  114. this.getuser()
  115. },
  116. methods: {
  117. confirm(e) {
  118. console.log('confirm', e)
  119. this.sex=e.value[0]
  120. this.show = false
  121. },
  122. bindUser(data){
  123. var that=this;
  124. that.sex=data.sex;
  125. that.age=data.age;
  126. that.habits=data.habits;
  127. that.illnessTime=data.illnessTime;
  128. that.disease=data.disease;
  129. that.familyDisease=data.familyDisease;
  130. that.isLine=data.isLine;
  131. that.constitution=data.constitution;
  132. that.medicine=data.medicine;
  133. that.consultProduct=data.consultProduct;
  134. that.isBuy=data.isBuy;
  135. },
  136. getuser(){
  137. const data={
  138. qwExternalContactId:this.externalUserId
  139. }
  140. getcustomer(data).then(res=>{
  141. if (res.code == 200) {
  142. this.detailUser=res.data
  143. // this.moreInfo=res.moreInfo
  144. this.name=res.data.name;
  145. this.bindUser(res.moreInfo);
  146. } else {
  147. uni.showToast({
  148. icon: 'none',
  149. title: res.msg
  150. })
  151. }
  152. })
  153. },
  154. // 性别选择
  155. pickerSex(e) {
  156. console.log(e)
  157. this.sex = e.detail.value
  158. },
  159. submit(){
  160. if (this.utils.isEmpty(this.sex)) {
  161. uni.showToast({
  162. title: "请输入性别",
  163. icon: 'none',
  164. });
  165. return
  166. }
  167. if (this.utils.isEmpty(this.age)) {
  168. uni.showToast({
  169. title: "请输入年龄",
  170. icon: 'none',
  171. });
  172. return
  173. }
  174. uni.showLoading({
  175. title: '加载中'
  176. });
  177. var data = {
  178. externalContactId:this.externalUserId,
  179. name:this.phonenumber,
  180. age:this.age,
  181. sex:this.sex.toString(),
  182. habits:this.habits,
  183. illnessTime:this.illnessTime,
  184. disease:this.disease,
  185. familyDisease:this.familyDisease,
  186. isLine:this.isLine,
  187. constitution:this.constitution,
  188. medicine:this.medicine,
  189. consultProduct:this.consultProduct,
  190. isBuy:this.isBuy
  191. };
  192. console.log(data);
  193. updataUser(data).then(
  194. res => {
  195. uni.hideLoading();
  196. if(res.code==200){
  197. uni.showToast({
  198. title: '修改成功',
  199. duration: 2000
  200. });
  201. // setTimeout(function() {
  202. // uni.navigateBack({
  203. // success: () => {
  204. // }
  205. // })
  206. // }, 500);
  207. this.getuser()
  208. }
  209. else{
  210. uni.showToast({
  211. title: res.msg,
  212. icon: 'none',
  213. });
  214. }
  215. },
  216. rej => {}
  217. );
  218. }
  219. }
  220. }
  221. </script>
  222. <style scoped lang="scss">
  223. .base-color-0{
  224. color: #000;
  225. }
  226. .content{
  227. padding-top: 20rpx;
  228. border-top: 1px solid #F5F6FA;
  229. }
  230. .info-item{
  231. height: 104upx;
  232. background: #FFFFFF;
  233. padding: 0 30upx;
  234. display: flex;
  235. align-items: center;
  236. justify-content: space-between;
  237. border-bottom: 1px solid #F5F6FA;
  238. &:last-child{
  239. border-bottom: none;
  240. }
  241. .label{
  242. font-size: 30upx;
  243. font-family: PingFang SC;
  244. font-weight: 400;
  245. color: #0F1826;
  246. }
  247. .right{
  248. display: flex;
  249. align-items: center;
  250. justify-content: center;
  251. .text{
  252. font-size: 30upx;
  253. font-family: PingFang SC;
  254. font-weight: 400;
  255. color: #0F1826;
  256. }
  257. .image{
  258. margin-left: 10upx;
  259. width: 30upx;
  260. height: 30upx;
  261. }
  262. .input{
  263. text-align: right;
  264. font-size: 30upx;
  265. font-family: PingFang SC;
  266. font-weight: 400;
  267. color: #0F1826;
  268. }
  269. }
  270. .head{
  271. border-radius: 50%;
  272. width: 80upx;
  273. height: 80upx;
  274. }
  275. .arrow{
  276. width: 30upx;
  277. height: 30upx;
  278. }
  279. .text{
  280. font-size: 30upx;
  281. font-family: PingFang SC;
  282. font-weight: 400;
  283. color: #0F1826;
  284. }
  285. .input{
  286. text-align: right;
  287. font-size: 30upx;
  288. font-family: PingFang SC;
  289. font-weight: 400;
  290. color: #0F1826;
  291. }
  292. &.password{
  293. margin-top: 20upx;
  294. .right{
  295. display: flex;
  296. align-items: center;
  297. .text{
  298. font-size: 30upx;
  299. font-family: PingFang SC;
  300. font-weight: 400;
  301. color: #0F1826;
  302. margin-right: 15upx;
  303. }
  304. }
  305. }
  306. }
  307. .btn-box{
  308. margin-top: 15rpx;
  309. padding: 0 30upx;
  310. position: fixed;
  311. bottom: 0;
  312. background-color: #FFFFFF;
  313. padding-top: 30rpx;
  314. padding-bottom: 30rpx;
  315. width: 100%;
  316. align-items: center;
  317. justify-content: center;
  318. .sub-btn{
  319. width: 100%;
  320. height: 88upx;
  321. line-height: 88upx;
  322. text-align: center;
  323. font-size: 30upx;
  324. font-family: PingFang SC;
  325. font-weight: bold;
  326. color: #FFFFFF;
  327. background: #078df3;
  328. border-radius: 44upx;
  329. }
  330. }
  331. </style>