selectInterview.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="container">
  3. <nav-bar :title="title" color="#000"></nav-bar>
  4. <view class="content">
  5. <view class="cell-box">
  6. <view class="cell-title">{{type == 'address'?'面试地点':'姓名'}}</view>
  7. <u-input disabled v-model="address" v-if="type=='address'" type="text" @click="selectAddress" :border="true"
  8. placeholder="请选择地址"/>
  9. <u-input v-else v-model="address" type="text" :border="true"
  10. :placeholder="type == 'address'?'请输入办公大楼名称,例:碧桂园凤凰智谷':'请输入联系人姓名'" />
  11. </view>
  12. <view class="cell-box">
  13. <view class="cell-title">{{type == 'address'?'楼层/单元室':'电话'}}</view>
  14. <div class="input-wrapper">
  15. <u-input v-model="floor" :type="type == 'address'?'text':'number'" :border="true"
  16. :placeholder="type == 'address'?'楼层/单元室/门牌号,例:3层302室':'请输入联系人电话'" @input="handleInput"
  17. :maxlength="20" />
  18. <view class="word-count" v-if="type == 'address'">{{ floorLength }}/20</view>
  19. </div>
  20. </view>
  21. </view>
  22. <button class="btn" :disabled="!canSave" @click="goBack">保存</button>
  23. </view>
  24. </template>
  25. <script>
  26. import navBar from "@/components/nav-bar/index.vue";
  27. export default {
  28. components: {
  29. navBar
  30. },
  31. data() {
  32. return {
  33. title: '面试地址',
  34. id: '',
  35. address: '',
  36. latitude:0,
  37. longitude:0,
  38. floor: '',
  39. floorLength: 0,
  40. callback: null,
  41. type: ''
  42. };
  43. },
  44. onLoad(options) {
  45. this.type = options.type
  46. if (this.type === 'address') {
  47. this.title = '面试地址'
  48. } else if (this.type === 'addPerson') {
  49. this.title = '添加联系人'
  50. } else if (this.type === 'editPerson') {
  51. this.title = '编辑联系人'
  52. }
  53. const eventChannel = this.getOpenerEventChannel();
  54. this.callback = null;
  55. eventChannel.on('sendData', (data) => {
  56. this.callback = data.callback;
  57. if (data.type === 'editPerson' && data.item) {
  58. this.id = data.item.id
  59. this.address = data.item.hrName
  60. this.floor = data.item.hrPhone
  61. }
  62. if (data.type === 'address' && data.item) {
  63. this.latitude = data.item.latitude
  64. this.longitude = data.item.longitude
  65. this.address = data.item.address
  66. this.floor = data.item.detailedAddress
  67. }
  68. })
  69. },
  70. computed: {
  71. canSave() {
  72. return this.address.trim() !== '' && this.floor.trim() !== '';
  73. }
  74. },
  75. methods: {
  76. handleInput(val) {
  77. this.floorLength = val.length;
  78. },
  79. goBack() {
  80. if (this.callback) {
  81. if (this.type === 'address') {
  82. this.callback({
  83. address: this.address,
  84. floor: this.floor,
  85. latitude:this.latitude,
  86. longitude:this.longitude
  87. })
  88. } else if (this.type === 'addPerson') {
  89. this.$Request.postJson('/app/interviewRecord/addHrPhone', {
  90. hrName: this.address, //会话对象的id
  91. hrPhone: this.floor, //当前登录者Id
  92. // type:2,
  93. }).then(ret => {
  94. if (ret.code == 0) {
  95. this.callback({
  96. id: Date.now(),
  97. hrName: this.address,
  98. hrPhone: this.floor
  99. })
  100. }
  101. })
  102. } else if (this.type === 'editPerson') {
  103. this.$Request.postJson('/app/interviewRecord/addHrPhone', {
  104. hrName: this.address,
  105. hrPhone: this.floor,
  106. // type:2,
  107. }).then(ret => {
  108. if (ret.code == 0) {
  109. this.callback({
  110. id: this.id,
  111. name: this.address,
  112. phone: this.floor
  113. })
  114. }
  115. })
  116. }
  117. }
  118. uni.navigateBack();
  119. },
  120. selectAddress: function() {
  121. var that = this;
  122. var latitude;
  123. var longitude;
  124. if (this.latitude != "") {
  125. latitude = this.latitude;
  126. longitude = this.longitude;
  127. that.chooseLocation(latitude, longitude);
  128. } else {
  129. if(this.$queue.getData('latitude')){
  130. latitude = this.$queue.getData('latitude');
  131. longitude = this.$queue.getData('longitude');
  132. }
  133. that.chooseLocation(latitude, longitude);
  134. }
  135. },
  136. chooseLocation(latitude, longitude) {
  137. var that = this;
  138. if (parseInt(latitude) <= 0) {
  139. latitude = "";
  140. longitude = "";
  141. }
  142. uni.chooseLocation({
  143. latitude: latitude,
  144. longitude: longitude,
  145. success: function(res) {
  146. console.log(res);
  147. if (res.latitude == undefined)
  148. return that.$common.toast("请选择一个地址");
  149. that.address = res.address + res.name;
  150. that.latitude = res.latitude;
  151. that.longitude = res.longitude;
  152. },
  153. fail: function(err) {
  154. console.log("选择位置失败:", err);
  155. },
  156. });
  157. },
  158. }
  159. };
  160. </script>
  161. <style scoped lang="scss">
  162. .container {
  163. display: flex;
  164. flex-direction: column;
  165. height: 100vh;
  166. .content {
  167. flex: 1;
  168. display: flex;
  169. flex-direction: column;
  170. z-index: 0;
  171. padding: 40rpx;
  172. .cell-box {
  173. margin-bottom: 32rpx;
  174. .cell-title {
  175. color: var(--Neutral/100, rgba(31, 44, 55, 1));
  176. font-family: DM Sans;
  177. font-size: 28rpx;
  178. font-weight: 500;
  179. line-height: 44rpx;
  180. letter-spacing: 0.5%;
  181. margin-bottom: 16rpx;
  182. }
  183. .input-wrapper {
  184. position: relative;
  185. .word-count {
  186. position: absolute;
  187. top: 50%;
  188. right: 26rpx;
  189. transform: translateY(-50%);
  190. color: rgba(153, 153, 153, 1);
  191. font-family: DM Sans;
  192. font-size: 24rpx;
  193. font-weight: 500;
  194. line-height: 48rpx;
  195. letter-spacing: 0.5%;
  196. }
  197. }
  198. ::v-deep .uni-input-placeholder {
  199. color: rgba(153, 153, 153, 1);
  200. font-family: DM Sans;
  201. font-size: 24rpx;
  202. font-weight: 500;
  203. line-height: 48rpx;
  204. letter-spacing: 0.5%;
  205. }
  206. ::v-deep .u-input {
  207. height: 70rpx;
  208. box-sizing: border-box;
  209. border: 1px solid rgba(227, 231, 236, 1);
  210. border-radius: 48rpx;
  211. background: rgba(255, 255, 255, 1);
  212. padding: 0 32rpx !important;
  213. box-sizing: border-box;
  214. text-align: left !important;
  215. }
  216. ::v-deep .uni-input-input {
  217. font-family: DM Sans;
  218. font-size: 24rpx !important;
  219. font-weight: 500;
  220. line-height: 48rpx;
  221. letter-spacing: 0.5%;
  222. color: #000 !important;
  223. }
  224. }
  225. }
  226. .btn {
  227. display: flex;
  228. height: 80rpx;
  229. // padding: 16rpx 32rpx;
  230. border-radius: 999px;
  231. background: rgba(255, 102, 0, 1);
  232. margin: 60rpx;
  233. color: rgba(255, 255, 255, 1);
  234. font-family: DM Sans;
  235. font-size: 32rpx;
  236. font-weight: 400;
  237. line-height: 80rpx;
  238. letter-spacing: 0%;
  239. box-sizing: border-box;
  240. justify-content: center;
  241. &:active {
  242. background: rgba(255, 102, 0, 0.8);
  243. }
  244. ::v-deep uni-button:after {
  245. border: none !important;
  246. }
  247. }
  248. uni-button[disabled] {
  249. background: rgba(255, 102, 0, 0.5) !important;
  250. }
  251. }
  252. </style>