part_time_push.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="main">
  3. <view class="form_group">
  4. <view class="lable re">兼职名称</view>
  5. <input placeholder="请输入" v-model="item.title" />
  6. </view>
  7. <view class="form_group">
  8. <view class="lable re">兼职类型</view>
  9. <picker :disabled="true" @click="go('/pages/job/position/classification')">
  10. <input placeholder="请选择" v-model="item.positionName" :disabled="true" />
  11. <view class="icon more">&#xe8f2;</view>
  12. </picker>
  13. </view>
  14. <view class="form_group">
  15. <view class="lable re">兼职描述(要求)</view>
  16. <leditor ref="editor" v-model="item.contents" placeholder="请输入兼职描述"></leditor>
  17. </view>
  18. <view class="form_group">
  19. <view class="lable re">兼职金额(元)</view>
  20. <view class="bgm">
  21. <input type="digit" placeholder="请输入" v-model="item.salary" class="input" />
  22. <view class="msg">
  23. <text>{{ money }}</text>
  24. <text @click="go('/pages/user/money/index')">充值</text>
  25. </view>
  26. </view>
  27. <view class="bz">
  28. <text class="icon">&#xe634;</text>
  29. <text>兼职金额从账户余额扣除,请保留充足的余额</text>
  30. </view>
  31. </view>
  32. <view class="form_group">
  33. <view class="lable re">兼职时间</view>
  34. </view>
  35. <view class="form_group" style="display: flex">
  36. <view class="start">
  37. <picker mode="date" :start="end" @change="picker($event, 'startDate')">
  38. <input placeholder="开始时间" v-model="item.startDate" :disabled="true" />
  39. </picker>
  40. </view>
  41. <view class="hor">至</view>
  42. <view class="start">
  43. <picker mode="date" :start="end" @change="picker($event, 'endDate')">
  44. <input placeholder="结束时间" v-model="item.endDate" :disabled="true" />
  45. </picker>
  46. </view>
  47. </view>
  48. <view class="form_group">
  49. <view class="lable">兼职地点</view>
  50. <picker :disabled="true" @click="chooseLocation()">
  51. <input :placeholder="item.type == 0 ? '请选择' : '留空不限工作地点'" v-model="item.location" :disabled="true" />
  52. <view class="icon more">&#xe8f2;</view>
  53. </picker>
  54. <input placeholder="请输入楼层/单元室/门牌号" v-model="item.mph" v-if="item.address" />
  55. <view class="bz">如需应聘者去现场请选择兼职地点</view>
  56. </view>
  57. <button class="btn" @click="save()">{{ item.id ? '编辑' : '保存' }}</button>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. money: 0,
  65. item: { type: 1 },
  66. end: this.util.getDate('day'),
  67. dict: {
  68. positionName: this.util.getData('positionName'),
  69. experience: this.util.getData('experience'),
  70. salary: [['面议'], ['']],
  71. location: this.util.getData('address'),
  72. unit: this.util.getData('unit')
  73. }
  74. };
  75. },
  76. onLoad(e) {
  77. if (e.id) {
  78. this.http.request({
  79. url: '/app/position/manage/detail/' + e.id,
  80. success: (res) => {
  81. this.item = res.data.data;
  82. this.$refs.editor.setContents();
  83. uni.setNavigationBarTitle({ title: '编辑兼职' });
  84. }
  85. });
  86. }
  87. uni.$on('select_position', (res) => {
  88. this.item.positionName = res.title;
  89. this.item.positionId = res.id;
  90. this.$forceUpdate();
  91. });
  92. },
  93. onShow() {
  94. this.money = uni.getStorageSync('money');
  95. },
  96. methods: {
  97. picker(e, tag) {
  98. if (tag == 'startDate' || tag == 'endDate') {
  99. this.item[tag] = e.detail.value;
  100. } else {
  101. this.item[tag] = this.dict[tag][e.detail.value];
  102. }
  103. this.$forceUpdate();
  104. },
  105. go(url) {
  106. uni.navigateTo({ url: url });
  107. },
  108. chooseLocation() {
  109. uni.chooseLocation({
  110. success: (res) => {
  111. let reg = /.+?(省|市|自治区|自治州|县|区)/g;
  112. let addressList = res.address.match(reg).toString().split(',');
  113. //注意区分直辖市;
  114. let city = addressList.length >= 3 ? addressList[1] : addressList[0];
  115. let region = addressList.length >= 3 ? addressList[2] : addressList[1];
  116. this.item.location = res.name;
  117. this.item.address = res.address;
  118. this.item.longitude = res.longitude;
  119. this.item.latitude = res.latitude;
  120. this.item.regionName = region;
  121. this.item.cityName = city;
  122. this.$forceUpdate();
  123. }
  124. });
  125. },
  126. save() {
  127. this.http.request({
  128. url: this.item.id ? '/app/position/manage/edit' : '/app/position/manage/add',
  129. data: this.item,
  130. method: 'POST',
  131. success: (res) => {
  132. //实名认证跳转
  133. if (res.data.code == 7878) {
  134. uni.showModal({
  135. title: '提示',
  136. content: res.data.msg,
  137. showCancel: false,
  138. success: (res) => {
  139. uni.navigateTo({ url: '/pages/user/auth' });
  140. }
  141. });
  142. return;
  143. }
  144. //余额不足,请先充值
  145. if (res.data.code == 8080) {
  146. uni.showModal({
  147. title: '提示',
  148. content: res.data.msg,
  149. showCancel: false,
  150. success: (res) => {
  151. uni.navigateTo({ url: '/pages/user/money/index' });
  152. }
  153. });
  154. return;
  155. }
  156. uni.showToast({ title: '操作成功' });
  157. setTimeout(() => {
  158. uni.$emit('position');
  159. uni.navigateBack();
  160. }, 1500);
  161. }
  162. });
  163. }
  164. }
  165. };
  166. </script>
  167. <style lang="scss">
  168. .bgm {
  169. .input {
  170. width: 50%;
  171. }
  172. .msg {
  173. text {
  174. padding-left: 17px;
  175. }
  176. }
  177. }
  178. </style>