addCompetitors.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="form-box">
  5. <view class="form-item">
  6. <text class="label">竞品公司<text class="color-price">*</text></text>
  7. <input class="input-width" type="text" v-model="form.competitorCompany" placeholder="请输入竞品公司"
  8. placeholder-class="form-input" />
  9. </view>
  10. <view class="form-item">
  11. <text class="label">产品<text class="color-price">*</text></text>
  12. <input class="input-width" type="text" v-model="form.product" placeholder="请输入产品"
  13. placeholder-class="form-input" />
  14. </view>
  15. <view class="form-item">
  16. <text class="label">价格<text class="color-price">*</text></text>
  17. <input class="input-width" type="digit" v-model="form.price" placeholder="请输入价格"
  18. placeholder-class="form-input" />
  19. </view>
  20. <view class="form-item">
  21. <text class="label">服务<text class="color-price">*</text></text>
  22. <input class="input-width" type="text" v-model="form.service" placeholder="请输入竞品公司服务方式"
  23. placeholder-class="form-input" />
  24. </view>
  25. <view class="form-item">
  26. <text class="label">免费服务次数<text class="color-price">*</text></text>
  27. <input class="input-width" type="number" v-model="form.freeServiceTimes" placeholder="请输入服务次数"
  28. placeholder-class="form-input" />
  29. </view>
  30. </view>
  31. </view>
  32. <view class="btn-box">
  33. <view class="sub-btn" @click="submit()">
  34. <image src="/static/images/health/nav_add_icon24.png" class="w48 h48"></image>
  35. <text>新增竞品信息</text>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. getCompetitorById,saveCompetitor,updateCompetitor
  43. } from '@/api/companyUser.js'
  44. export default {
  45. data() {
  46. return {
  47. type: null,
  48. patientId: null,
  49. famaleurl:"/static/images/health/female_profile.png",
  50. maleurl:"/static/images/health/my_heads.png",
  51. checked:1,
  52. array:['是','否'],
  53. tags: [{
  54. name: '心脏病',
  55. checked:true,
  56. id: 1
  57. },
  58. {
  59. name: '脑梗死',
  60. checked:false,
  61. id: 2
  62. },{
  63. name: '肾病',
  64. checked:false,
  65. id: 3
  66. },{
  67. name: '脂肪肝',
  68. checked:false,
  69. id: 4
  70. }],
  71. form: {
  72. "competitorCompany": null,
  73. "freeServiceTimes":null,
  74. "price":null,
  75. "product": null,
  76. "remark": null,
  77. "service": null,
  78. },
  79. id:null
  80. };
  81. },
  82. onLoad(options) {
  83. this.type = options.type;
  84. this.form.userId=options.userId
  85. this.form.companyUserId=options.companyUserId;
  86. console.log(this.type)
  87. if (this.type == 'edit') {
  88. this.id=options.id;
  89. this.getCompetitorInfo();
  90. }
  91. },
  92. methods: {
  93. getCompetitorInfo() {
  94. var data = {
  95. id: this.id
  96. };
  97. getCompetitorById(data).then(
  98. res => {
  99. if (res.code == 200) {
  100. this.form = res.data;
  101. } else {
  102. uni.showToast({
  103. title: res.msg,
  104. });
  105. }
  106. },
  107. rej => {}
  108. );
  109. },
  110. submit() {
  111. if (this.form.competitorCompany == null || this.form.competitorCompany == '') {
  112. uni.showToast({
  113. icon: 'none',
  114. title: "公司名称不能为空",
  115. });
  116. return;
  117. }
  118. if (this.form.product == null || this.form.product == '') {
  119. uni.showToast({
  120. icon: 'none',
  121. title: "产品不能为空",
  122. });
  123. return;
  124. }
  125. if (this.form.price == null || this.form.price == '') {
  126. uni.showToast({
  127. icon: 'none',
  128. title: "价格不能为空",
  129. });
  130. return;
  131. }
  132. if (this.form.service == null || this.form.service == '') {
  133. uni.showToast({
  134. icon: 'none',
  135. title: "服务不能为空",
  136. });
  137. return;
  138. }
  139. if (this.form.freeServiceTimes == null || this.form.freeServiceTimes == '') {
  140. uni.showToast({
  141. icon: 'none',
  142. title: "次数不能为空",
  143. });
  144. return;
  145. }
  146. if (this.type == "add") {
  147. this.saveCompetitor()
  148. } else if (this.type == "edit") {
  149. this.updateCompetitor()
  150. }
  151. },
  152. updateCompetitor() {
  153. updateCompetitor(this.form).then(
  154. res => {
  155. if (res.code == 200) {
  156. uni.showToast({
  157. icon: 'success',
  158. title: "操作成功",
  159. });
  160. setTimeout(function() {
  161. uni.$emit('refreshBuyOrder');
  162. uni.navigateBack({
  163. delta: 1
  164. })
  165. }, 500);
  166. } else {
  167. uni.showToast({
  168. icon: 'none',
  169. title: res.msg,
  170. });
  171. }
  172. },
  173. rej => {}
  174. );
  175. },
  176. saveCompetitor() {
  177. saveCompetitor(this.form).then(
  178. res => {
  179. if (res.code == 200) {
  180. uni.showToast({
  181. icon: 'success',
  182. title: "操作成功",
  183. });
  184. setTimeout(function() {
  185. uni.$emit('refreshBuyOrder');
  186. uni.navigateBack({
  187. delta: 1
  188. })
  189. }, 500);
  190. } else {
  191. uni.showToast({
  192. icon: 'none',
  193. title: res.msg,
  194. });
  195. }
  196. },
  197. rej => {}
  198. );
  199. },
  200. }
  201. }
  202. </script>
  203. <style lang="scss">
  204. page {
  205. height: 100%;
  206. }
  207. .content {
  208. height: 100%;
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: space-between;
  212. .inner {
  213. // height: calc(100% - 120upx);
  214. padding: 20upx;
  215. .form-box {
  216. padding: 0 30upx;
  217. background: #FFFFFF;
  218. border-radius: 16upx;
  219. margin-bottom: 20upx;
  220. .form-title {
  221. font-family: PingFang SC;
  222. font-weight: 600;
  223. font-size: 40rpx;
  224. color: #222426;
  225. text-align: left;
  226. padding: 30rpx 0;
  227. display: block;
  228. }
  229. .form-item {
  230. padding: 30upx 0;
  231. display: flex;
  232. align-items: flex-start;
  233. border-bottom: 1px solid #F1F1F1;
  234. &:last-child {
  235. border-bottom: none;
  236. }
  237. .label {
  238. width: 300upx;
  239. text-align: left;
  240. font-size: 32upx;
  241. line-height: 44upx;
  242. font-family: PingFang SC;
  243. font-weight: 500;
  244. color: #222222;
  245. flex-shrink: 0;
  246. }
  247. input {
  248. text-align: right;
  249. }
  250. .form-input {
  251. font-size: 30upx;
  252. font-family: PingFang SC;
  253. font-weight: 500;
  254. color: #999999;
  255. text-align: right;
  256. }
  257. .form-item-tag{
  258. margin-right: 16rpx;
  259. .tag{
  260. border-radius: 8rpx 8rpx 8rpx 8rpx;
  261. border: 2rpx solid #ECECEC;
  262. display: flex;
  263. align-items: center;
  264. padding: 24rpx;
  265. font-family: PingFang SC;
  266. font-weight: 400;
  267. font-size: 24rpx;
  268. &.active{
  269. background: #F0FAFF;
  270. border: 2rpx solid #008FD3;
  271. color: #008FD3;
  272. }
  273. }
  274. }
  275. .right{
  276. display: flex;
  277. align-items: center;
  278. }
  279. .sex-box{
  280. flex:1;
  281. display: flex;
  282. align-items: center;
  283. justify-content: flex-end;
  284. .sex-item{
  285. width: 146rpx;
  286. height: 64rpx;
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. background: #F5F7FA;
  291. border-radius: 32rpx 32rpx 32rpx 32rpx;
  292. margin-left: 16rpx;
  293. .u-icon__icon{
  294. margin: 0;
  295. }
  296. text{
  297. // font-family: PingFang SC, PingFang SC;
  298. font-weight: 400;
  299. font-size: 28rpx;
  300. color: #898E91;
  301. margin-left: 12rpx;
  302. }
  303. &.active{
  304. background: #FCF0E7;
  305. text{
  306. color:#FF5030
  307. }
  308. }
  309. }
  310. }
  311. .form-textarea{
  312. font-size: 30upx;
  313. color: #999999;
  314. height: 100upx;
  315. padding: 4upx 0;
  316. }
  317. .birth-picker {
  318. flex: 1;
  319. display: flex;
  320. align-items: center;
  321. .right-box{
  322. width: 100%;
  323. display: flex;
  324. align-items: center;
  325. .input-box{
  326. // width: 470upx;
  327. }
  328. .arrow{
  329. width: 13upx;
  330. height: 23upx;
  331. margin-left: 20upx;
  332. }
  333. }
  334. }
  335. }
  336. }
  337. }
  338. .btn-box {
  339. height: 120upx;
  340. padding: 0 30upx;
  341. display: flex;
  342. align-items: center;
  343. justify-content: center;
  344. // position: fixed;
  345. // width: 90%;
  346. // bottom: 0;
  347. // left: 50%;
  348. // transform: translate(-50%,-50%);
  349. // background: #FFFFFF;
  350. .sub-btn {
  351. width: 100%;
  352. height: 88upx;
  353. line-height: 88upx;
  354. text-align: center;
  355. font-size: 32upx;
  356. font-family: PingFang SC;
  357. font-weight: bold;
  358. color: #FFFFFF;
  359. background: #008FD3 ;
  360. border-radius: 44upx;
  361. margin-bottom: 40upx;
  362. display: flex;
  363. align-items: center;
  364. justify-content: center;
  365. image{
  366. margin-right: 16rpx;
  367. }
  368. }
  369. }
  370. }
  371. </style>