winfo.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <view class="cu-list menu sm-border">
  4. <view class="cu-item arrow" @click="goHome">
  5. <view class="content">
  6. <text class="cuIcon-friend text-grey"></text>
  7. <text>切换身份</text>
  8. </view>
  9. </view>
  10. </view>
  11. <form>
  12. <view class="cu-form-group margin-top-sm">
  13. <view class="title">雇主类型</view>
  14. <input class="text-gray" placeholder="请输入..." data-field="wtype" name="wtype" :value="workerinfo.wtype==1?'个人雇主':'企业雇主'"
  15. disabled="true"></input>
  16. </view>
  17. <view class="cu-form-group">
  18. <view class="title">公司名称</view>
  19. <input placeholder="请输入..." data-field="title" name="title" :value="workerinfo.title" disabled="true"></input>
  20. </view>
  21. <view class="cu-form-group">
  22. <view class="title">微店名称</view>
  23. <input placeholder="请输入..." data-field="ftitle" name="ftitle" :value="workerinfo.ftitle" disabled="true"></input>
  24. </view>
  25. <view class="padding-lr padding-tb-sm text-gray text-sm">上面信息不可修改</view>
  26. <view class="cu-form-group">
  27. <view class="title">姓名</view>
  28. <input placeholder="请输入..." data-field="realname" name="realname" :value="workerinfo.realname" @input="setInput"></input>
  29. </view>
  30. <view class="cu-form-group">
  31. <view class="title">手机号</view>
  32. <input placeholder="请输入..." data-field="mobile" name="mobile" :value="workerinfo.mobile" @input="setInput"></input>
  33. </view>
  34. <view class="cu-form-group">
  35. <view class="title">微信号</view>
  36. <input placeholder="请输入..." data-field="weixin" name="weixin" :value="workerinfo.weixin" @input="setInput"></input>
  37. </view>
  38. <view class="cu-form-group">
  39. <view class="title">公开电话</view>
  40. <picker mode="selector" @change="isPublicPickerChange" :value="isPublicIndex" :range="isPublicPickerList" :range-key="`text`">
  41. <view class="picker padding-tb text-df" style="font-size: 30rpx;line-height:40rpx;text-align:left;">{{isPublicIndex>-1 ? isPublicPickerList[isPublicIndex].text : ("请选择...")}}</view>
  42. </picker>
  43. </view>
  44. <view class="cu-form-group margin-top-sm">
  45. <view class="title">微店图标</view>
  46. <view class="cu-avatar radius bg-gray">
  47. <avatar selWidth="640upx" selHeight="640upx" @upload="setTilpic" :avatarSrc="workerinfo.tilpic" noTab="true"
  48. avatarStyle="width: 75upx; height: 75upx; border-radius: 5%;"></avatar>
  49. </view>
  50. </view>
  51. <view class="cu-form-group margin-top-sm">
  52. <view class="title">所属地区</view>
  53. <view style="text-align: left; flex: 1; font-size: 30rpx;">
  54. <pickerAddress @change="regionChange">{{workerinfo.province}} {{workerinfo.city}} {{workerinfo.district}}</pickerAddress>
  55. </view>
  56. </view>
  57. <view class="cu-form-group">
  58. <view class="title">详细地址</view>
  59. <input placeholder="请输入..." data-field="address" name="address" :value="workerinfo.address" @input="setInput"></input>
  60. </view>
  61. <view class="cu-form-group align-start">
  62. <view class="title">公司介绍</view>
  63. <textarea maxlength="-1" placeholder="请输入..." data-field="details" name="details" :value="workerinfo.details"
  64. @input="setInput"></textarea>
  65. </view>
  66. <view class="padding flex flex-direction">
  67. <button class="cu-btn bg-themeBtn margin-tb-sm lg" @tap="editWorker">立即提交</button>
  68. </view>
  69. <view class="padding"></view>
  70. </form>
  71. </view>
  72. </template>
  73. <script>
  74. var _this;
  75. import avatar from "@/components/yq-avatar/yq-avatar.vue";
  76. import pickerAddress from "@/components/pickerAddress/pickerAddress.vue";
  77. export default {
  78. components: {
  79. avatar,
  80. pickerAddress
  81. },
  82. data() {
  83. return {
  84. userinfo: {},
  85. isRotate: false,
  86. workerinfo: false,
  87. isPublicPickerList: [
  88. {id:1, text: '是'},
  89. {id:2, text: '否'},
  90. ],
  91. isPublicIndex: -1,
  92. isPublicValue: {
  93. id: false,
  94. text: false,
  95. },
  96. }
  97. },
  98. onLoad: function() {
  99. _this = this;
  100. _this.workerinfo = uni.getStorageSync('workerinfo') || false;
  101. if (_this.workerinfo === false) {
  102. uni.reLaunch({
  103. url: "/pages/my/my"
  104. });
  105. return false;
  106. }
  107. if(_this.workerinfo.is_public >= 1) {
  108. _this.isPublicIndex = _this.workerinfo.is_public - 1;
  109. _this.isPublicValue.text = _this.isPublicPickerList[_this.isPublicIndex].text;
  110. _this.isPublicValue.id = _this.isPublicPickerList[_this.isPublicIndex].id;
  111. }
  112. },
  113. methods: {
  114. // 填写字段
  115. setTilpic: function(rsp) {
  116. _this.setPic(rsp, "tilpic");
  117. },
  118. setPicone: function(rsp) {
  119. _this.setPic(rsp, "picone");
  120. },
  121. setPictwo: function(rsp) {
  122. _this.setPic(rsp, "pictwo");
  123. },
  124. setPicthr: function(rsp) {
  125. _this.setPic(rsp, "picthr");
  126. },
  127. setPic: function(rsp, picfield) {
  128. _this.$req.ajaxFile({
  129. path: "attachment/tplfieldimage",
  130. title: '正在上传',
  131. filePath: rsp.path,
  132. fileName: 'file',
  133. }).then((filedata) => {
  134. var data = JSON.parse(filedata.data);
  135. _this.workerinfo[picfield] = data.data.src;
  136. }).catch((err) => {
  137. uni.showModal({
  138. title: '信息提示',
  139. content: err,
  140. showCancel: false
  141. });
  142. });
  143. },
  144. setInput: function(e) {
  145. var field = e.currentTarget.dataset.field;
  146. _this.workerinfo[field] = e.detail.value;
  147. },
  148. regionChange: function(data) {
  149. _this.workerinfo.province = data.data[0];
  150. _this.workerinfo.city = data.data[1];
  151. _this.workerinfo.district = data.data[2];
  152. },
  153. //公开电话
  154. isPublicPickerChange: function(e) {
  155. console.log(e);
  156. _this.workerinfo.is_public = e.detail.value - 0 + 1;
  157. _this.isPublicIndex = e.detail.value;
  158. _this.isPublicValue.text = _this.isPublicPickerList[_this.isPublicIndex].text;
  159. _this.isPublicValue.id = _this.isPublicPickerList[_this.isPublicIndex].id;
  160. },
  161. goHome: function() {
  162. _this.userinfo = _this.checkLogin("/pages/my/my");
  163. if (_this.userinfo === false) {
  164. return false;
  165. }
  166. uni.setStorageSync('identityinfo', true);
  167. uni.setStorageSync('workerinfo', null);
  168. uni.reLaunch({
  169. url: "/pages/index/index"
  170. });
  171. },
  172. // 提交修改
  173. editWorker: function() {
  174. if (_this.isRotate) {
  175. return false;
  176. }
  177. _this.isRotate = true;
  178. _this.$req.ajax({
  179. path: "worker/editworker",
  180. title: "正在提交修改",
  181. data: {
  182. id: _this.workerinfo.id,
  183. userid: _this.workerinfo.userid,
  184. tilpic: _this.workerinfo.tilpic,
  185. realname: _this.workerinfo.realname,
  186. mobile: _this.workerinfo.mobile,
  187. position: _this.workerinfo.position,
  188. weixin: _this.workerinfo.weixin,
  189. province: _this.workerinfo.province,
  190. city: _this.workerinfo.city,
  191. district: _this.workerinfo.district,
  192. address: _this.workerinfo.address,
  193. details: _this.workerinfo.details,
  194. is_public:_this.workerinfo.is_public,
  195. }
  196. }).then((data) => {
  197. uni.setStorageSync('workerinfo', data.worker);
  198. uni.showModal({
  199. title: '信息提示',
  200. content: '公司信息修改成功。',
  201. showCancel: false,
  202. success: function(res) {
  203. if (res.confirm) {
  204. uni.redirectTo({
  205. url: "/pages/worker/worker"
  206. });
  207. }
  208. }
  209. });
  210. _this.isRotate = false;
  211. }).catch((err) => {
  212. uni.showModal({
  213. title: '信息提示',
  214. content: err,
  215. showCancel: false
  216. });
  217. _this.isRotate = false;
  218. });
  219. }
  220. }
  221. }
  222. </script>
  223. <style>
  224. .cu-form-group .title {
  225. min-width: calc(5em + 15px);
  226. }
  227. .fieldpic {
  228. width: 150rpx;
  229. height: 150rpx;
  230. }
  231. .fieldpictil {
  232. width: 230rpx;
  233. text-align: center;
  234. }
  235. </style>